How to use the @aws-amplify/auth.signUp function in @aws-amplify/auth

To help you get started, we’ve selected a few @aws-amplify/auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yhenni1989 / ReactNativeAuth / src / components / screens / SignUpScreen.js View on Github external
async signUp() {
    const { username, password, email, phoneNumber } = this.state
    // rename variable to conform with Amplify Auth field phone attribute
    const phone_number = phoneNumber
    await Auth.signUp({
      username,
      password,
      attributes: { email, phone_number }
    })
    .then(() => {
      console.log('sign up successful!')
      Alert.alert('Enter the confirmation code you received.')
    })
    .catch(err => {
      if (! err.message) {
        console.log('Error when signing up: ', err)
        Alert.alert('Error when signing up: ', err)
      } else {
        console.log('Error when signing up: ', err.message)
        Alert.alert('Error when signing up: ', err.message)
      }
github TreeHacks / root / src / store / auth / actions.ts View on Github external
return dispatch => {
    if (data.password !== data.password2) {
      dispatch(onAuthError("Passwords do not match."));
      return;
    }

    let email = data.email.toLowerCase().trim();

    dispatch(loadingStart());
    Auth.signUp({
      username: email,
      password: data.password,
      attributes: {
        email: email,
        name: "User",
        ["custom:location"]: data.location,
        website: [location.protocol, '//', location.host, location.pathname].join('') // Link for confirmation email
      }
    })
      .then(() => dispatch(setAuthPage("signIn", "Account creation complete. Please check your email for a confirmation link to confirm your email address, then sign in below. If you don't see the email, please check your spam folder.")))
      .catch(e => dispatch(onAuthError(e.message)))
      .then(() => dispatch(loadingEnd()))
  }
}
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / SignUp.tsx View on Github external
if (field.label === this.getUsernameLabel()) {
				logger.debug(`Changing the username to the value of ${field.label}`);
				signup_info.username =
					signup_info.attributes[field.key] || signup_info.username;
				labelCheck = true;
			}
		});
		if (!labelCheck && !signup_info.username) {
			// if the customer customized the username field in the sign up form
			// He needs to either set the key of that field to 'username'
			// Or make the label of the field the same as the 'usernameAttributes'
			throw new Error(
				`Couldn't find the label: ${this.getUsernameLabel()}, in sign up fields according to usernameAttributes!`
			);
		}
		Auth.signUp(signup_info)
			.then(data => {
				// @ts-ignore
				this.changeState('confirmSignUp', data.user.username);
			})
			.catch(err => this.error(err));
	}
github systemaccounting / mxfactorial / react / src / lib / amplify.js View on Github external
export const signUp = (credentials, attributes) =>
  Auth.signUp(credentials, attributes)
github josephluck / internote / ui / auth / auth.ts View on Github external
async function signUp(email: string) {
    await Auth.signUp({
      username: email,
      password: getRandomString(30)
    });
  }
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / SignUp.jsx View on Github external
const inputKeys = Object.keys(this.inputs);
        const inputVals = Object.values(this.inputs);

        inputKeys.forEach((key, index) => {
            if (!['username', 'password', 'checkedValue', 'dial_code'].includes(key)) {
              if (key !== 'phone_line_number' && key !== 'dial_code' && key !== 'error') {
                const newKey = `${this.needPrefix(key) ? 'custom:' : ''}${key}`;
                signup_info.attributes[newKey] = inputVals[index];
              } else if (inputVals[index]) {
                  signup_info.attributes['phone_number'] = `${this.inputs.dial_code}${this.inputs.phone_line_number.replace(/[-()]/g, '')}`
              }
            }
        });

        Auth.signUp(signup_info).then((data) => {
            this.changeState('confirmSignUp', data.user.username)
        })
        .catch(err => this.error(err));
    }
github awslabs / aws-full-stack-template / assets / src / modules / signup / Signup.tsx View on Github external
onSignup = (event: React.FormEvent) => {
    event.preventDefault()

    if (event.currentTarget.checkValidity() === false) {
      event.stopPropagation();
    } else {
      this.setState({ loading: true, validated: true });

      Auth.signUp({
        username: this.state.email,
        password: this.state.password
      }).then((value: ISignUpResult) => {
        this.setState({ user: value.user, loading: false });
      }).catch((e: any) => {
        alert(e.message);
        this.setState({ loading: false });
      });
    }
    this.setState({ validated: true });

  }