Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send verification link via email #4540

Open
2 of 14 tasks
erickotsuka opened this issue Mar 11, 2024 · 5 comments
Open
2 of 14 tasks

Unable to send verification link via email #4540

erickotsuka opened this issue Mar 11, 2024 · 5 comments
Assignees
Labels
auth Issues related to the Auth Category feature-request A request for a new feature or an enhancement to an existing API or category. service-team

Comments

@erickotsuka
Copy link

erickotsuka commented Mar 11, 2024

Description

Even after overriding and setting the verification message template to CONFIRM_WITH_LINK, the method Amplify.Auth.sendUserAttributeVerificationCode still sends a code via email, ignoring what is configured in AWS Cognito. There is no method for verification link. For context, the user is being auto-confirmed during the pre-sign up Lambda trigger. After the user signs in, I want to ask them to verify the email via link.

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. amplify override auth
  2. Add the following to override:
  resources.userPool.emailVerificationMessage = undefined
  resources.userPool.emailVerificationSubject = undefined
  resources.userPool.verificationMessageTemplate = {
    defaultEmailOption: 'CONFIRM_WITH_LINK',
    emailMessageByLink: `Please click the link below to verify your email address.
{##Verify Email##}`,
    emailSubjectByLink: 'Verify your email',
  }
  1. amplify push
  2. Call Amplify.Auth.sendUserAttributeVerificationCode(userAttributeKey: AuthUserAttributeKey.email); somewhere in the app after the user is signed in
  3. Sign in to the app and make the method above be called

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.19.2

Amplify Flutter Version

1.6.1

Deployment Method

Amplify CLI

Schema

No response

@Equartey Equartey added auth Issues related to the Auth Category pending-triage This issue is in the backlog of issues to triage labels Mar 12, 2024
@Equartey
Copy link
Contributor

Hi @erickotsuka, sorry you're experiencing this issue.

Can you please clarify step 1 of your reproduction steps? Where is this override occurring?

What version of Amplify CLI are you using?

Can you also please provide your amplifyconfiguration.dart file, making sure to remove any sensitive data?

@Equartey Equartey added the pending-response Issue is pending response from the issue requestor label Mar 14, 2024
@erickotsuka
Copy link
Author

Ideally I should make a minimal example, I can do that in a few days, but for now I will try to describe it. If it is not enough information, I can provide a minimal example later.

  1. Create a flutter up with a sign up page that the user can enter email and password and a button to sign up.
  2. Do the amplify initialization process (https://docs.amplify.aws/flutter/start/project-setup/create-application/)
  3. amplify add auth
  4. Choose the options to allow sign in via email and password, using only Cognito (no other provider). No MFA. Add a pre sign up lambda trigger.
  5. In the pre sign up lambda trigger, set the event.response.autoConfirmUser to true and return the event.
  6. amplify override auth. This should create the file amplify/backend/auth/<app name>/override.ts
  7. Place the following in override.ts:
import {
  AmplifyAuthCognitoStackTemplate,
  AmplifyProjectInfo,
} from '@aws-amplify/cli-extensibility-helper'

export function override(resources: AmplifyAuthCognitoStackTemplate, _: AmplifyProjectInfo) {
  resources.userPool.emailVerificationMessage = undefined
  resources.userPool.emailVerificationSubject = undefined
  resources.userPool.verificationMessageTemplate = {
    defaultEmailOption: 'CONFIRM_WITH_LINK',
    emailMessageByLink:
      'Please click the link below to verify your email address. {##Verify Email##}',
    emailSubjectByLink: 'Verify your email',
  }
}
  1. Change the on pressed callback for the sign up button to call, awaiting each call: Amplify.Auth.signUp(email, password), then Amplify.Auth.signIn(email, password) and then Amplify.Auth.sendUserAttributeVerificationCode(userAttributeKey: AuthUserAttributeKey.email).
  2. amplify push
  3. Run the flutter app for android in the android emulator
  4. Enter a valid email and a password, then click on the sign up button
  5. Check the email received. The issue is that the email being sent is with a verification code instead of a verification link

I am using version 12.10.1 of the amplify CLI.

@Equartey Equartey added to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided and removed pending-response Issue is pending response from the issue requestor labels Mar 22, 2024
@Equartey
Copy link
Contributor

@erickotsuka this is really helpful, thank you. It should be sufficient to reproduce. We'll investigate and provide an update when we can.

@khatruong2009 khatruong2009 self-assigned this Mar 28, 2024
@khatruong2009 khatruong2009 added the Investigating Issues that are assigned and are being looked into label Mar 28, 2024
@NikaHsn NikaHsn removed the pending-triage This issue is in the backlog of issues to triage label Mar 28, 2024
@khatruong2009
Copy link
Contributor

Hi @erickotsuka, I followed your reproduction steps and was able to reproduce this issue. I'm going to mark it as a bug and we are going to discuss it as a team and will keep you updated on the next steps of this issue, thanks.

@khatruong2009 khatruong2009 added bug Something is not working; the issue has reproducible steps and has been reproduced and removed to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Mar 29, 2024
@Jordan-Nelson
Copy link
Contributor

@erickotsuka - After speaking with Cognito, using a link confirmation is not supported for attribute confirmation. It is only supported for sign up confirmation. I will update this to a feature request. However, this would first require Cognito to support it.

@Jordan-Nelson Jordan-Nelson added feature-request A request for a new feature or an enhancement to an existing API or category. and removed bug Something is not working; the issue has reproducible steps and has been reproduced Investigating Issues that are assigned and are being looked into labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth Category feature-request A request for a new feature or an enhancement to an existing API or category. service-team
Projects
None yet
Development

No branches or pull requests

5 participants