Amplify-js: How to resend verification code while verifying/updating email/phone attribute in aws-amplify/ aws-cognito?

Created on 13 Feb 2020  路  6Comments  路  Source: aws-amplify/amplify-js

* Which Category is your question related to? *
Auth
* What AWS Services are you utilizing? *
Cognito
* Provide additional details e.g. code snippets *
How to resend verification code while verifying/updating email/phone attribute in aws-amplify/ aws-cognito, I'm using this code, to verify email/phone:

const responce = await Auth.verifyCurrentUserAttributeSubmit("email", confirmationCode)
Is there a possibility to resend the code?

Cognito question

Most helpful comment

@manueliglesias I have already found a solution I used verifyCurrentUserAttribute() method to resend a code.

updateUserAttributes doesn't resend code to the same email/phone number.

All 6 comments

Hi @Luckygirlllll

I've been digging around and found this related issue #1614 and feature request #2010

Looks like at the moment the way to have the code sent again is to try the updateUserAttribute operation again.

Please let us know if this works for you

@manueliglesias I have already found a solution I used verifyCurrentUserAttribute() method to resend a code.

updateUserAttributes doesn't resend code to the same email/phone number.

@Luckygirlllll Thank you for posting your solution for other users to see!

This is not applicable to MFA scenario so please remove link to feature 2010.

Don't know if this would help. This actually solved my problem:

import { Auth } from 'aws-amplify';

async function resendConfirmationCode() {
    try {
        await Auth.resendSignUp(username);
        console.log('code resent successfully');
    } catch (err) {
        console.log('error resending code: ', err);
    }
}

Source Link: https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js#re-send-confirmation-code

@novusli according to your answer, what should be the status of the user in the Pool in Cognito NEW_PASSWORD_REQUIRED or CONFIRMED?
Because I tried with both cases without success.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leantide picture leantide  路  3Comments

shinnapatthesix picture shinnapatthesix  路  3Comments

benevolentprof picture benevolentprof  路  3Comments

DougWoodCDS picture DougWoodCDS  路  3Comments

oste picture oste  路  3Comments