23
votes

I am using Amazon Cognito Identity SDK for JavaScript (deprecated).

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?

2
you can also use this by skipping the otp step they mention stackoverflow.com/a/66267032/8782229Robinson Calderón

2 Answers

17
votes

Actually, AWS has recently added the ability to verify email and verify phone number in the pre-signup lambda as well. You basically need to set autoVerifyEmail and autoVerifyPhone in the lambda and they will get verified. More info in the official documentation.

"response": {
    "autoConfirmUser": boolean
    "autoVerifyEmail": boolean
    "autoVerifyPhone": boolean
}
37
votes

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.