I'm having issues with resending the confirmation code for cases where for some reason the confirmation code was not delivered to the users. This is what I have:
First, I have a sign-up step:
const cognito = new AWS.CognitoIdentityServiceProvider({region});
const params = {
ClientId,
Username,
Password,
};
const result = await cognito.signUp(params).promise();
This step (in case of success) should send an email to the user's email address (which is also their username) with their confirmation code. Now let's assume for some reason that email is not sent (the reason itself is not important). I would like to provide a chance to the user to ask for a new email to be sent. These are what I've been testing for this purpose so far:
First, I've tested the resendConfirmationCode method:
const cognito = new AWS.CognitoIdentityServiceProvider({region});
const params = {
ClientId,
Username,
};
const result = await cognito.resendConfirmationCode(params).promise();
Executing this code throws this error message:
UnhandledPromiseRejectionWarning: NotAuthorizedException: Cannot resend codes. Auto verification not turned on.
Then, I tested this approach (because of the answer given in this post):
const cognito = new AWS.CognitoIdentityServiceProvider({region});
const params = {
UserPoolId,
Username,
DesiredDeliveryMediums: ["EMAIL"],
ForceAliasCreation: false,
MessageAction: "RESEND",
}
const result = await cognito.adminCreateUser(params).promise();
This time, I'm getting this error:
UnhandledPromiseRejectionWarning: UnsupportedUserStateException: Resend not possible. ********-****-****-****-********** status is not FORCE_CHANGE_PASSWORD
The retracted part is the user's sub.
So, does anyone know how I can resend the confirmation code for a user that is not confirmed yet?