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 provide ClientMetadata within the required password reset flow #6238

Open
4 tasks done
PaulVPrivateaser opened this issue Dec 6, 2024 · 1 comment
Open
4 tasks done
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature

Comments

@PaulVPrivateaser
Copy link

PaulVPrivateaser commented Dec 6, 2024

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

Angular

Which UI component?

Authenticator

How is your app built?

Angular CLI

What browsers are you seeing the problem on?

Chrome

Which region are you seeing the problem in?

No response

Please describe your bug.

What is working

After importing users to a Cognito pool, the user is in the RESET_PASSWORD state.
When the user tries to sign in, they are sent to the ConfirmPasswordReset screen and asked for a code.
Cognito then proceeds to send an email with the code.

Unfortunately, it seems that we’re not able to customize this email appropriately.

What is not working

We are localizing emails sent by Cognito through the use of a lambda (https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-custom-message.html).

To pass the appropriate locale, we override some services (handleSignIn and handleForgotPassword) to provide it through the clientMetdata dict.

@Component({
  template: `<amplify-authenticator [services]="services"></amplify-authenticator>`
})
class AuthPage {
  ngOnInit(){
    const language = "fr";
    this.services = {
      async handleForgotPassword(input: ResetPasswordInput): Promise<ResetPasswordOutput> {
          return await resetPassword({
              ...input,
              options: {
                  ...input.options,
                  clientMetadata: {
                      locale: language
                  }
              }
          });
      },
      async handleSignUp(input: SignUpInput): Promise<SignUpOutput> {
          return await signUp({
              ...input,
              options: {
                  ...input.options,
                  userAttributes: input.options?.userAttributes || {},
                  clientMetadata: {
                      locale: language
                  }
              }
          });
      }
    }
  }
}

Unfortunately, it seems that the handleForgotPassword is not called in the case of the “PasswordResetRequired” flow, thus preventing us to pass the appropriate locale.

As per our understanding of the workflow, handleForgotPassword should be called when sending the email with the password reset code (see above) but this is not the case.

Are we overriding the right service? Is there an underlying issue within the angular implementation?

What's the expected behaviour?

The ‘password reset required’ workflow should call the user-overriden service handleForgotPassword , allowing developpers to customize this workflow.

Help us reproduce the bug!

  1. Import a user or otherwise get them in the "Reset Password" state
  2. Customize your app to override clientMetadata in the handleForgotPassword service
  3. Go to the app and attempt to sign in with the username and any password
  4. Check network calls : the call to AWSCognitoIdentityProviderService.ForgotPassword does not contain the clientMetadata

Code Snippet

No response

Console log output

InitiateAuth payload :

{
  "AuthFlow": "USER_SRP_AUTH",
  "AuthParameters": {
    "USERNAME": "user_email",
    "SRP_A": "token"
  },
  "ClientMetadata": { "locale": "fr" },
  "ClientId": "client_id"
}

ForgotPassword payload :

{ "Username": "user_email", "ClientId": "client_id" }

Additional information and screenshots

Related issue : #2488

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify UI maintainer labels Dec 6, 2024
@calebpollman
Copy link
Member

@PaulVPrivateaser Thanks for bringing this to our attention, we will look in to it

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify UI maintainer label Dec 9, 2024
@cwomack cwomack added feature-request Request a new feature Authenticator An issue or a feature-request for an Authenticator UI Component and removed pending-triage Issue is pending triage labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Authenticator An issue or a feature-request for an Authenticator UI Component feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

3 participants