Click the link confirmation auth amplify
Asked Answered
P

2

0

How can I use "click the confirmation link" authentication instead of confirmation code authentication with AWS Cognito?

The confirm user email currently looks like this:

enter image description here

Piny answered 3/5, 2021 at 15:23 Comment(0)
S
3

You can set that in Cognito user pool settings under General Settings > Message Customizations > Do you want to customize your email verification messages? > Verification type. Choose Link.

Or if you use CDK, you can set it in code.

const userPool = new UserPool(this, "userPool", {
  userVerification: {
    emailStyle: VerificationEmailStyle.LINK,
  }
  ...
Sihun answered 3/5, 2021 at 15:57 Comment(1)
Looks like the settings are no longer available in the new redesigned UI. What URL is Cognito supposed to generate for the verification link? Will it point to the Amazon hosted pages?Octillion
B
1

If you want to do it the Amplify way you can create an auth override (amplify override auth) and make the following override.ts file:

import { AmplifyAuthCognitoStackTemplate } from '@aws-amplify/cli-extensibility-helper';

export function override(resources: AmplifyAuthCognitoStackTemplate) {
  resources.userPool.addPropertyOverride('VerificationMessageTemplate', {
    ...(resources.userPool.verificationMessageTemplate as any),
    // Let users confirm their email with a link instead of a code
    DefaultEmailOption: 'CONFIRM_WITH_LINK',
    // Optional contents of message, only supported if using SES for sending emails
    EmailMessage: `Please verify your email address by visiting {##this link##}.`,
  });
}

Source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-verificationmessagetemplate.html

Budge answered 19/10, 2023 at 17:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.