aws-sdk-js icon indicating copy to clipboard operation
aws-sdk-js copied to clipboard

Resend MFA Code for login process

Open Deepesh316 opened this issue 5 years ago • 9 comments

Is your feature request related to a problem? Please describe. I have been searching for resending mfa code (via SMS) for login process in aws-sdk. But not able to find any possible method for implementing the same.

Requirement:

  1. MFA is set to required in cognito.( through SMS )
  2. User enters Login username and password
  3. User is redirected to Verify MFA code page
  4. Now comes the edge case where user doesn't receives code on phone due to network issues or some other issues. Hence we need to provide user with option to resend MFA code

As per my understanding from the documentation, resend OTP is possible for signup. resend-otp-for-signup

Describe the solution you'd like A way to re-send MFA Code due to some edge case a user does not receive code in the initial signIn flow. We need a similar functionality like resendConfirmationCode.

Deepesh316 avatar Oct 10 '20 10:10 Deepesh316

Try resending login details.

naveenkumardot25 avatar Feb 02 '21 04:02 naveenkumardot25

is there a solution? Cognito seems very immature and committing to it a mistake.

s1mrankaur avatar Apr 29 '21 19:04 s1mrankaur

With OTP codes we work around it like this.

We send a custom challenge answer that contains metadata which indicates the code should be resend.

  const askToResendOtpCode = async () => {
      const cognitoUser = await Auth.sendCustomChallengeAnswer(session, '0', {'resend': 'yes'})
      alert("OTP code has been resend. Give it a minute.")
  }

Then in your create challenge trigger lambda function check the metadata on the request:

const shouldResendCode = event.request.clientMetadata?.resend === 'yes' ? true : false;
...
      if(shouldResendCode){
        console.log("Asked to resend the code, will do")
        await sendSms(phoneNumber, secretLoginCode)
      }
...

This way the client has the option to ask for the code to be send again.

Nxtra avatar Jan 02 '22 12:01 Nxtra

@Nxtra Which AWS cognito API endpoint did you use for this? The logic that you shared, did you write this in the lambda triggers?

mandeepm91 avatar Mar 17 '22 18:03 mandeepm91

2 years later and this hasn't been resolved

StephenOkeleke97 avatar Oct 30 '22 05:10 StephenOkeleke97

Any update, guys?

cunguyen-agilityio avatar May 09 '23 02:05 cunguyen-agilityio

Same, would appreciate a method like resendMFaCode. Right now have to reauthenticate the user to trigger another code.

jmnProcom avatar Jun 06 '23 20:06 jmnProcom

The feature is being worked upon by the cognito team as detailed #6676

samsiis avatar Sep 06 '23 22:09 samsiis

+1

dvargas10Pearls avatar Jan 25 '24 18:01 dvargas10Pearls