1

So I use lambda pre signup tigger in Cognito to do custom email. When I try to set autoVerifyEmail=true I get the fowllowing error:

Phone or email cannot be auto verified, when user is not being auto confirmed.

so what's the point of this lambda trigger if I change any of event details and I still get the error. My goal here is to implement custom email verification that will use admin_confirm_sign_up() to verify user in the end.

Gleb Oleg
  • 107
  • 1
  • 7

2 Answers2

0

You can auto confirm the user as well.

Vasileios Lekakis
  • 5,492
  • 2
  • 15
  • 17
0

In addition to auto-confirming email or phone, you need to flag the user for auto-confirmation:

// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-sign-up.html#aws-lambda-triggers-pre-registration-example-2
export const handler = async(event) => {
    event.response.autoConfirmUser = true;
    event.response.autoVerifyEmail = true;
    return event;
};

Just a note that auto-verification like this generally goes against best practices:

When new users sign up in your app, you probably want them to provide at least one contact method...

...it's important that you send your messages to a verified destination. Otherwise, you might send your messages to an invalid email address or phone number that was typed incorrectly. Or worse, you might send sensitive information to bad actors who pose as your users.

Tim
  • 159
  • 1
  • 8