Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 366f929

Browse files
[Phone Auth] No event when clicking "cancel" on verification Prompt #1082
1 parent 1bc61fe commit 366f929

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/firebase-common.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ export const firebase: any = {
143143
requestPhoneAuthVerificationCode: (onUserResponse, verificationPrompt) => {
144144
prompt(verificationPrompt || "Verification code").then(promptResult => {
145145
if (!promptResult.result) {
146-
return;
146+
onUserResponse(undefined);
147+
} else {
148+
onUserResponse(promptResult.text);
147149
}
148-
onUserResponse(promptResult.text);
149150
});
150151
},
151152
// for backward compatibility, because plugin version 4.0.0 moved the params to per-logintype objects

src/firebase.android.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,10 @@ firebase.login = arg => {
878878
if (firebase._verifyPhoneNumberInProgress) {
879879
firebase._verifyPhoneNumberInProgress = false;
880880
firebase.requestPhoneAuthVerificationCode(userResponse => {
881+
if (userResponse === undefined && this.reject) {
882+
this.reject("Prompt was canceled");
883+
return;
884+
}
881885
const authCredential = com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, userResponse);
882886
const user = com.google.firebase.auth.FirebaseAuth.getInstance().getCurrentUser();
883887

src/firebase.ios.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ firebase.login = arg => {
779779
}
780780

781781
firebase.requestPhoneAuthVerificationCode(userResponse => {
782+
if (userResponse === undefined) {
783+
reject("Prompt was canceled");
784+
return;
785+
}
782786
const fIRAuthCredential = FIRPhoneAuthProvider.provider().credentialWithVerificationIDVerificationCode(verificationID, userResponse);
783787
if (fAuth.currentUser) {
784788
const onCompletionLink = (authData: FIRAuthDataResult, error: NSError) => {

0 commit comments

Comments
 (0)