* 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?
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.
Most helpful comment
@manueliglesias I have already found a solution I used
verifyCurrentUserAttribute()method to resend a code.updateUserAttributesdoesn't resend code to the same email/phone number.