Skip to content

Commit

Permalink
feat(auth, android): implement disable app verification feature on an…
Browse files Browse the repository at this point in the history
…droid (#6069)

* feat(auth, android): add android for disable app verification feature
* chore(auth, lint): fixup unused import

Co-authored-by: Mike Hardy <[email protected]>
  • Loading branch information
Duell10111 and mikehardy authored Feb 13, 2022
1 parent 55dc55c commit 48c7842
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,23 @@ public void setAutoRetrievedSmsCodeForPhoneNumber(
promise.resolve(null);
}

/**
* Disable app verification for the running of tests
* @param appName
* @param disabled
* @param promise
*/
@ReactMethod
public void setAppVerificationDisabledForTesting(
String appName, boolean disabled, Promise promise) {
Log.d(TAG, "setAppVerificationDisabledForTesting");
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance(firebaseApp);
FirebaseAuthSettings firebaseAuthSettings = firebaseAuth.getFirebaseAuthSettings();
firebaseAuthSettings.setAppVerificationDisabledForTesting(disabled);
promise.resolve(null);
}

@ReactMethod
public void signOut(String appName, Promise promise) {
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
Expand Down
8 changes: 3 additions & 5 deletions packages/auth/lib/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

import { isAndroid, isIOS } from '@react-native-firebase/app/lib/common';
import { isAndroid } from '@react-native-firebase/app/lib/common';

export default class Settings {
constructor(auth) {
Expand All @@ -28,10 +28,8 @@ export default class Settings {
}

set appVerificationDisabledForTesting(disabled) {
if (isIOS) {
this._appVerificationDisabledForTesting = disabled;
this._auth.native.setAppVerificationDisabledForTesting(disabled);
}
this._appVerificationDisabledForTesting = disabled;
this._auth.native.setAppVerificationDisabledForTesting(disabled);
}

setAutoRetrievedSmsCodeForPhoneNumber(phoneNumber, smsCode) {
Expand Down
3 changes: 1 addition & 2 deletions packages/auth/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,10 @@ export namespace FirebaseAuthTypes {
*/
export interface AuthSettings {
/**
* iOS only flag to disable app verification for the purpose of testing phone authentication. For this property to take effect, it needs to be set before rendering a reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is useful for manual testing during development or for automated integration tests.
* Flag to disable app verification for the purpose of testing phone authentication. For this property to take effect, it needs to be set before rendering a reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is useful for manual testing during development or for automated integration tests.
*
* > In order to use this feature, you will need to [whitelist your phone number](https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers) via the Firebase Console.
*
* @ios
* @param disabled Boolean value representing whether app verification should be disabled for testing.
*/
appVerificationDisabledForTesting: boolean;
Expand Down

1 comment on commit 48c7842

@vercel
Copy link

@vercel vercel bot commented on 48c7842 Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.