Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cognito - Create user without sending them a verification email

I'm trying to disable the verification process for some users that I register myself(admin).

I've added the pre-signup lambda like the documentation says:

```exports.handler = (event, context, callback) => {

// Confirm the user
    event.response.autoConfirmUser = true;

// Set the email as verified if it is in the request
if (event.request.userAttributes.hasOwnProperty("email")) {
    event.response.autoVerifyEmail = true;
}

// Set the phone number as verified if it is in the request
if (event.request.userAttributes.hasOwnProperty("phone_number")) {
    event.response.autoVerifyPhone = true;
}

// Return to Amazon Cognito
callback(null, event);

};

And the email verification is still coming to the user.

I've also tried using the adminConfirmSignUp api to confirm the user right after I create it with adminCreateUser. But this is the error i'm getting when using the adminConfirmSignUp

{ NotAuthorizedException: User cannot be confirmed. Current status is FORCE_CHANGE_PASSWORD

Is there any other way that I can make it to not send the verification email to some users?

like image 876
Arlind Avatar asked Nov 16 '19 21:11

Arlind


People also ask

How do I verify my email on AWS Cognito?

Amazon Cognito can automatically verify email addresses or phone numbers. To do this verification, Amazon Cognito sends a verification code or a verification link. For email addresses, Amazon Cognito can send a code or a link in an email message. For phone numbers, Amazon Cognito sends a code in an SMS text message.

How do I verify a Cognito user?

Call the SignUp API action, and provide the email address and phone number for the UserAttributes parameter. At this point, Amazon Cognito sends a verification code to the user's phone. In your app interface, present a confirmation page where the user enters the verification code.


Video Answer


1 Answers

I got this to working by just including these 2 properties inside the request when creating the user.

DesiredDeliveryMediums: [],
MessageAction: "SUPPRESS"

No need for pre-signup lambda.

like image 104
Arlind Avatar answered Oct 20 '22 15:10

Arlind