aws / aws-sdk-js

AWS SDK for JavaScript in the browser and Node.js
https://aws.amazon.com/developer/language/javascript/
Apache License 2.0
7.59k stars 1.55k forks source link

Resend MFA Code for login process #3488

Closed Deepesh316 closed 6 months ago

Deepesh316 commented 4 years ago

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.

naveenkumardot25 commented 3 years ago

Try resending login details.

s1mrankaur commented 3 years ago

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

Nxtra commented 2 years ago

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.

mandeepm91 commented 2 years ago

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

StephenOkeleke97 commented 1 year ago

2 years later and this hasn't been resolved

cunguyen-agilityio commented 1 year ago

Any update, guys?

jmnProcom commented 1 year ago

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

samsiis commented 1 year ago

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

dvargas10Pearls commented 9 months ago

+1

kennydifiore commented 3 months ago

+1 Following