Table of Contents

Implementation

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;
}

Js Auth

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

Cognito Js Auth Sign Up