This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
Ignore callbacks for previous phone number auth entered #1765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisite
Disable android timeout by setting it to 0
Context
On every call to
login
type phone, Firebase generates a verification id. If this function is called several times before submitting an SMS code, at the time this happens, Firebase returns all the verification ids accumulated to theonCodeSent->requestPhoneAuthVerificationCode
(android) orcredentialWithVerificationIDVerificationCode
(iOS) one by one.Use Case
A user enters a phone number and clicks on login. Then the user realizes the phone number is wrong, resets the form, sets a proper number, clicks on login, gets an SMS code and submit this code to verify the login.
Steps to reproduce
Observed Results
It generates 2 different callbacks to
requestPhoneAuthVerificationCode(android)/credentialWithVerificationIDVerificationCode(iOS)
. I found out 2 different outcomes so far.Expected Results
The last phone number sent to the login function should be the only one logging in.
Solution proposed
verificationId
to verify, in a variable.onCodeSent
receives theverificationId
, save the 'current'verificationId
in a the variable. Each callback can now reference a snapshot of theverificationId
that is being verified.requestPhoneAuthVerificationCode(android)/credentialWithVerificationIDVerificationCode(iOS)
function of the OnVerificationStateChangedCallbacks object that is passed to verifyPhoneNumber, check if the actual 'current'verificationId
to verify is equal to theverificationId
that was captured/enclosed by the callback object -- if theverificationId
don't match, stop execution.