vovan
vovan

Reputation: 1540

Resend verification code Firebase Phone Authenticate

I added Firebase Phone Authenticate to my mobile app. Standard flow:

  1. input phone number
  2. wait for the verification code
  3. get the verification code
  4. put the verification code

Sometimes the user has broken flow (SMS does not come along):

  1. input phone number
  2. did not wait for the verification code
  3. click "resend verification code"
  4. get first (stale) verification code
  5. input the first verification code
  6. get an error message (verification code is invalid)

In the second scenario, the user could avoid a problem if after click user get the same verification code. Has Firebase certain settings? (although this somewhat reduces the security of authorization over the phone). With the javascript API, is there a way to 'resend' the same verification code?

Upvotes: 0

Views: 1757

Answers (1)

bojeil
bojeil

Reputation: 30848

You can try adding a timer after they click to send the SMS code which would wait for some time (15seconds) before allowing the user to resent the code. FirebaseUI uses that mechanism to take into account SMS delays.

On the other hand, this shouldn't be a problem, Firebase Auth will resend the same code for the same session within a short period of time apart. So if the user enters an older code (code from successive attempts), it will still work.

Upvotes: 2

Related Questions