Cognito - Sign-Up

> AWS (Amazon Web Services) > Aws - Cognito

2 - Implementation

2.1 - Amplify

Cognito - Amplify Auth Component

aws amplify sign-up

import { Auth } from 'aws-amplify';
 
Auth.signUp({
    username,
    password,
    attributes: {
        email,          // optional
        phone_number,   // optional - E.164 number convention
        // other custom attributes 
    },
    validationData: []  //optional
    })
    .then(data => console.log(data))
    .catch(err => console.log(err));
 
// After retrieving the confirmation code from the user
Auth.confirmSignUp(username, code, {
    // Optional. Force user confirmation irrespective of existing alias. By default set to True.
    forceAliasCreation: true    
}).then(data => console.log(data))
  .catch(err => console.log(err));
 
Auth.resendSignUp(username).then(() => {
    console.log('code resent successfully');
}).catch(e => {
    console.log(e);
});

The Auth.signUp promise returns a data object of type ISignUpResult with a CognitoUser.

{
    user: CognitoUser;
    userConfirmed: boolean;
    userSub: string;
}
Advertising

2.2 - Js Auth

The hosted sign up forms of the Cognito - Js Auth Sdk library.

aws/cognito/sign_up.txt · Last modified: 2019/06/04 09:15 by gerardnico