Skip to content

Commit

Permalink
fix: pass autoOTPVerify only to necessary functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Efstathios Ntonas committed Nov 19, 2024
1 parent 57fb872 commit 5a96645
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions packages/auth/lib/PhoneAuthListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down Expand Up @@ -56,7 +55,6 @@ export default class PhoneAuthListener {
this._phoneAuthRequestId + '',
this._timeout,
this._forceResending,
this._autoOTPVerify,
);
}

Expand Down
21 changes: 11 additions & 10 deletions packages/auth/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,30 +294,31 @@ class FirebaseAuthModule extends FirebaseModule {
verifyPhoneNumber(phoneNumber, autoVerifyTimeoutOrForceResend, forceResend) {
let _forceResend = forceResend;
let _autoVerifyTimeout = 60;
let _autoOTPVerify = this._settings.autoOTPVerify;

if (isBoolean(autoVerifyTimeoutOrForceResend)) {
_forceResend = autoVerifyTimeoutOrForceResend;
} else {
_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(

Check warning on line 308 in packages/auth/lib/index.js

View check run for this annotation

Codecov / codecov/patch

packages/auth/lib/index.js#L308

Added line #L308 was not covered by tests
multiFactorHint.uid,
session,
this._settings.autoOTPVerify,
);
}

verifyPhoneNumberForMultiFactor(phoneInfoOptions) {
const { phoneNumber, session } = phoneInfoOptions;
return this.native.verifyPhoneNumberForMultiFactor(phoneNumber, session);
return this.native.verifyPhoneNumberForMultiFactor(

Check warning on line 317 in packages/auth/lib/index.js

View check run for this annotation

Codecov / codecov/patch

packages/auth/lib/index.js#L317

Added line #L317 was not covered by tests
phoneNumber,
session,
this._settings.autoOTPVerify,
);
}

resolveMultiFactorSignIn(session, verificationId, verificationCode) {
Expand Down

0 comments on commit 5a96645

Please sign in to comment.