From 44278f59cc659cbcabb2291ca823b3724beee742 Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Thu, 26 Oct 2017 17:06:34 +0100 Subject: [PATCH] [auth][android] Make sure email field is populated for password providers --- .../io/invertase/firebase/auth/RNFirebaseAuth.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java index d4bc7a1f..214fb724 100644 --- a/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java +++ b/android/src/main/java/io/invertase/firebase/auth/RNFirebaseAuth.java @@ -33,6 +33,7 @@ import com.google.firebase.auth.ActionCodeResult; import com.google.firebase.auth.AuthCredential; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException; +import com.google.firebase.auth.FirebaseAuthProvider; import com.google.firebase.auth.GithubAuthProvider; import com.google.firebase.auth.PhoneAuthCredential; import com.google.firebase.auth.PhoneAuthProvider; @@ -1287,7 +1288,7 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule { for (UserInfo userInfo : providerData) { // remove 'firebase' provider data - android fb sdk // should not be returning this as the ios/web ones don't - if (!userInfo.getProviderId().equals("firebase")) { + if (!FirebaseAuthProvider.PROVIDER_ID.equals(userInfo.getProviderId())) { WritableMap userInfoMap = Arguments.createMap(); userInfoMap.putString("providerId", userInfo.getProviderId()); userInfoMap.putString("uid", userInfo.getUid()); @@ -1308,7 +1309,12 @@ class RNFirebaseAuth extends ReactContextBaseJavaModule { userInfoMap.putNull("phoneNumber"); } - userInfoMap.putString("email", userInfo.getEmail()); + // The Android SDK is missing the email property for the email provider, so we use UID instead + if (EmailAuthProvider.PROVIDER_ID.equals(userInfo.getProviderId())) { + userInfoMap.putString("email", userInfo.getUid()); + } else { + userInfoMap.putString("email", userInfo.getEmail()); + } output.pushMap(userInfoMap); }