5
votes

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?

1

1 Answers

5
votes

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.