javascriptamazon-cognitoaws-amplify

Unable to signIn a user without email confirmation AWS Amplify


I recently set up authentication on Cognito via Amplify and am trying to set up mail verification. This verification can be done as long as the user has just created an account. However, I can't send the code for mail verification via the sendUserAttributeVerificationCode function in the “aws-amplify/auth” package because my user needs to be authenticated to call it. What do I do if my user registers, leaves the page without checking his e-mail and tries to log in again? If I delete the localStorage from my browser, I have no way of recovering the account? The account has already been created, so I can't re-create an account with the same e-mail address, and I can't log in because I haven't checked my e-mail address.


Solution

  • Upon further investigation, it seems that AWS has added a resendSignUpCode function to their “aws-amplify/auth” package that doesn't require a logged-in user to work. The implementation is as follows:

    await resendSignUpCode({ username: email });
    

    It works perfectly for me like this