amplify-ui icon indicating copy to clipboard operation
amplify-ui copied to clipboard

PasswordResetRequiredException does not trigger code email

Open adilosa opened this issue 2 years ago • 1 comments

Before creating a new issue, please confirm:

On which framework/platform are you having an issue?

React

Which UI component?

Authenticator

How is your app built?

Create React App / Webpack 5

What browsers are you seeing the problem on?

Firefox, Chrome

Please describe your bug.

After importing users to a Cognito pool, the user is in the RESET_PASSWORD state [1]. When the user tries to sign in, they are kicked to the ConfirmPasswordReset screen and asked for a code, but a code email is never sent.

This case is not currently handled in the UI.

If the user manually presses "Resend Code" the code email is immediately sent.

[1] https://docs.aws.amazon.com/cognito/latest/developerguide/signing-up-users-in-your-app.html#signup-confirmation-verification-overview

What's the expected behaviour?

A code email should be sent automatically.

Help us reproduce the bug!

  1. Import a user or otherwise get them in the "Reset Password" state
  2. Go to the app and attempt to sign in with the username and any password
  3. Arrive at the ConfirmPasswordReset screen with no code in your email inbox
  4. Press "Resend Code" and see the code email received normally

example Cognito import CSV (may not match your user pool):

name,given_name,family_name,middle_name,nickname,preferred_username,profile,picture,website,email,email_verified,gender,birthdate,zoneinfo,locale,phone_number,phone_number_verified,address,updated_at,cognito:mfa_enabled,cognito:username
,,,,,,,,,[email protected],True,,,,,,False,,,False,[email protected]

Code Snippet

No response

Additional information and screenshots

Workaround:

I modified the handleSignIn() function to intercept the "PasswordResetRequiredException" and manually send the code using Auth.forgotPassword() (the same function the "Resend Code" button calls). This effectively manually presses "Resend Code" in this case without interrupting the UI flow.

<Authenticator
  services={{
    async handleSignIn({ username, password }) {
      return Auth.signIn(username, password).catch(error => {
        if (error.code === "PasswordResetRequiredException") {
          Auth.forgotPassword(username);
        }
        throw error;
      });
    },
  }}
  ...
/>

adilosa avatar Aug 19 '22 01:08 adilosa

@adilosa Thank you for your detailed bug report, we'll prioritize fixing this on our roadmap and update this issue accordingly.

slaymance avatar Aug 19 '22 04:08 slaymance

Hi @adilosa !

I'm trying to reproduce this and I have not been able too. Is this still happening to you?

ErikCH avatar Dec 19 '22 23:12 ErikCH

Hi @ErikCH! Thanks for following up. Yes, I just tried again and was able to repo the issue.

I'm using [email protected] and @aws-amplify/[email protected].

I tested by modifying the example CSV above to create a 'new' user email with a suffix. I use [email protected] to create additional accounts I can still receive email for. After importing the CSV into my Cognito User Pool, the new user is created and in the "Reset required" state as expected.

Then, I go to my app and try and sign in via the Amplify UI Components login flow (not-hosted). It correctly brings me to the Reset Password screen but still does not send the code until I manually hit "Resend Code", at which point I get the email almost instantly, repeatedly and every time.

adilosa avatar Dec 20 '22 02:12 adilosa

Hi @adilosa ! I was able to reproduce this issue. It should be out on our next release! Or you can install it and test it out using the @next tag @aws-amplify/ui-react@next !

ErikCH avatar Dec 23 '22 19:12 ErikCH

Hey @adilosa, this has been released in @aws-amplify/[email protected]. Please reopen the issue if the issue persists after the upgrade, thanks!

wlee221 avatar Jan 05 '23 19:01 wlee221

Hey @wlee221 and @ErikCH, I'm on @aws-amplify/[email protected] now and can confirm it's working as expected without my workaround. Thanks so much!

adilosa avatar Jan 26 '23 02:01 adilosa