How to confirm user in Cognito User Pools without verifying email or phone?

Dmitry Grinko picture Dmitry Grinko · Nov 18, 2017 · Viewed 9.1k times · Source

I am using Amazon Cognito Identity SDK for JavaScript.

I created new pool without verifying email and phone_number.

By default, users aren't confirmed in Cognito User Pools, so I need to do this manually.

How to confirm user in Cognito User Pools without verifying email or phone?

Answer

Ula picture Ula · Nov 8, 2018

I hope this will help someone else.

To do this you can add this Lambda function:

exports.handler = (event, context, callback) => {
    event.response.autoConfirmUser = true;
    event.response.autoVerifyEmail = true;  // this is NOT needed if e-mail is not in attributeList
    event.response.autoVerifyPhone = true;  // this is NOT needed if phone # is not in attributeList
    context.done(null, event);
};

Then navigate to AWS Cognito's General settings >> Triggers and add this Lambda function to 'Pre sign-up' - click the drop down list and select Lambda function with above code.

If you only use 'preferred_username' (if no e-mail or phone # is used) setting event.response.autoConfirmUser to true is sufficient.