From 8bcf5c945db5614835630b6d0cf4951c4a5b2a2d Mon Sep 17 00:00:00 2001 From: Mike Diarmid Date: Fri, 15 May 2020 13:35:00 +0100 Subject: [PATCH] fix(auth): use correct code on network exception (#3655) Fixes #3654. [publish] --- .../auth/ReactNativeFirebaseAuthModule.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 f5af96c247..c9aed9753d 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 @@ -32,6 +32,7 @@ import com.google.android.gms.tasks.OnCompleteListener; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseException; +import com.google.firebase.FirebaseNetworkException; import com.google.firebase.auth.ActionCodeResult; import com.google.firebase.auth.ActionCodeSettings; import com.google.firebase.auth.AuthCredential; @@ -1773,9 +1774,13 @@ private WritableMap getJSError(Exception exception) { } } - if (code.equals("UNKNOWN") && exception instanceof FirebaseAuthInvalidCredentialsException) { - code = "INVALID_EMAIL"; - message = invalidEmail; + if (code.equals("UNKNOWN")) { + if (exception instanceof FirebaseAuthInvalidCredentialsException) { + code = "INVALID_EMAIL"; + message = invalidEmail; + } else if (exception instanceof FirebaseNetworkException) { + code = "NETWORK_REQUEST_FAILED"; + } } code = code @@ -1910,7 +1915,7 @@ private WritableMap firebaseUserToMap(FirebaseUser user) { private ActionCodeSettings buildActionCodeSettings(ReadableMap actionCodeSettings) { ActionCodeSettings.Builder builder = ActionCodeSettings.newBuilder(); - + // Required String url = actionCodeSettings.getString("url"); builder = builder.setUrl(Objects.requireNonNull(url));