From 5a96645834f01afab3f1ce83b394752cd18b918f Mon Sep 17 00:00:00 2001 From: Efstathios Ntonas Date: Tue, 19 Nov 2024 12:19:47 +0200 Subject: [PATCH] fix: pass autoOTPVerify only to necessary functions --- .../auth/ReactNativeFirebaseAuthModule.java | 14 +++++++------ packages/auth/lib/PhoneAuthListener.js | 4 +--- packages/auth/lib/index.js | 21 ++++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java b/packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java index b8c2293144..db1ce355b9 100644 --- a/packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java +++ b/packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java @@ -984,8 +984,8 @@ public void signInWithPhoneNumber( String appName, final String phoneNumber, final boolean forceResend, - final Promise promise, - final boolean autoOTPVerify) { + final boolean autoOTPVerify, + final Promise promise) { Log.d(TAG, "signInWithPhoneNumber"); FirebaseApp firebaseApp = FirebaseApp.getInstance(appName); final FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp); @@ -1126,8 +1126,9 @@ public void verifyPhoneNumberWithMultiFactorInfo( final String appName, final String hintUid, final String sessionKey, - final Promise promise, - final boolean autoOTPVerify) { + final boolean autoOTPVerify, + final Promise promise + ) { final MultiFactorResolver resolver = mCachedResolvers.get(sessionKey); if (resolver == null) { // See https://firebase.google.com/docs/reference/node/firebase.auth.multifactorresolver for @@ -1199,8 +1200,9 @@ public void verifyPhoneNumberForMultiFactor( final String appName, final String phoneNumber, final String sessionKey, - final Promise promise, - final boolean autoOTPVerify) { + final boolean autoOTPVerify, + final Promise promise + ) { final MultiFactorSession multiFactorSession = mMultiFactorSessions.get(sessionKey); if (multiFactorSession == null) { rejectPromiseWithCodeAndMessage( diff --git a/packages/auth/lib/PhoneAuthListener.js b/packages/auth/lib/PhoneAuthListener.js index a455321951..9d5378a7f0 100644 --- a/packages/auth/lib/PhoneAuthListener.js +++ b/packages/auth/lib/PhoneAuthListener.js @@ -21,13 +21,12 @@ import NativeFirebaseError from '@react-native-firebase/app/lib/internal/NativeF let REQUEST_ID = 0; export default class PhoneAuthListener { - constructor(auth, phoneNumber, timeout, forceResend, autoOTPVerify) { + constructor(auth, phoneNumber, timeout, forceResend) { this._auth = auth; this._reject = null; this._resolve = null; this._promise = null; this._jsStack = new Error().stack; - this._autoOTPVerify = autoOTPVerify; this._timeout = timeout || 20; this._phoneAuthRequestId = REQUEST_ID++; @@ -56,7 +55,6 @@ export default class PhoneAuthListener { this._phoneAuthRequestId + '', this._timeout, this._forceResending, - this._autoOTPVerify, ); } diff --git a/packages/auth/lib/index.js b/packages/auth/lib/index.js index 1f6ad93d08..ad59b58dbd 100644 --- a/packages/auth/lib/index.js +++ b/packages/auth/lib/index.js @@ -294,7 +294,6 @@ class FirebaseAuthModule extends FirebaseModule { verifyPhoneNumber(phoneNumber, autoVerifyTimeoutOrForceResend, forceResend) { let _forceResend = forceResend; let _autoVerifyTimeout = 60; - let _autoOTPVerify = this._settings.autoOTPVerify; if (isBoolean(autoVerifyTimeoutOrForceResend)) { _forceResend = autoVerifyTimeoutOrForceResend; @@ -302,22 +301,24 @@ class FirebaseAuthModule extends FirebaseModule { _autoVerifyTimeout = autoVerifyTimeoutOrForceResend; } - return new PhoneAuthListener( - this, - phoneNumber, - _autoVerifyTimeout, - _forceResend, - _autoOTPVerify, - ); + return new PhoneAuthListener(this, phoneNumber, _autoVerifyTimeout, _forceResend); } verifyPhoneNumberWithMultiFactorInfo(multiFactorHint, session) { - return this.native.verifyPhoneNumberWithMultiFactorInfo(multiFactorHint.uid, session); + return this.native.verifyPhoneNumberWithMultiFactorInfo( + multiFactorHint.uid, + session, + this._settings.autoOTPVerify, + ); } verifyPhoneNumberForMultiFactor(phoneInfoOptions) { const { phoneNumber, session } = phoneInfoOptions; - return this.native.verifyPhoneNumberForMultiFactor(phoneNumber, session); + return this.native.verifyPhoneNumberForMultiFactor( + phoneNumber, + session, + this._settings.autoOTPVerify, + ); } resolveMultiFactorSignIn(session, verificationId, verificationCode) {