4646import com .google .firebase .auth .FirebaseAuth ;
4747import com .google .firebase .auth .FirebaseAuthException ;
4848import com .google .firebase .auth .FirebaseAuthInvalidCredentialsException ;
49+ import com .google .firebase .auth .FirebaseAuthUserCollisionException ;
4950import com .google .firebase .auth .FirebaseAuthMultiFactorException ;
5051import com .google .firebase .auth .FirebaseAuthProvider ;
5152import com .google .firebase .auth .FirebaseAuthSettings ;
@@ -868,9 +869,12 @@ private void signInWithCredential(
868869 @ ReactMethod
869870 public void signInWithProvider (String appName , String providerId , @ Nullable String email , Promise promise ){
870871 OAuthProvider .Builder provider = OAuthProvider .newBuilder (providerId );
872+
871873 if (email != null ){
872874 provider .addCustomParameter ("login_hint" , email );
873875 }
876+ provider .addCustomParameter ("prompt" , "select_account" );
877+
874878 Activity activity = getCurrentActivity ();
875879 FirebaseApp firebaseApp = FirebaseApp .getInstance (appName );
876880 FirebaseAuth firebaseAuth = FirebaseAuth .getInstance (firebaseApp );
@@ -908,9 +912,12 @@ public void onFailure(@NonNull Exception e) {
908912 @ ReactMethod
909913 public void linkWithProvider (String appName , String providerId , @ Nullable String email , Promise promise ){
910914 OAuthProvider .Builder provider = OAuthProvider .newBuilder (providerId );
915+
911916 if (email != null ){
912917 provider .addCustomParameter ("login_hint" , email );
913918 }
919+ provider .addCustomParameter ("prompt" , "select_account" );
920+
914921 Activity activity = getCurrentActivity ();
915922 FirebaseApp firebaseApp = FirebaseApp .getInstance (appName );
916923 FirebaseAuth firebaseAuth = FirebaseAuth .getInstance (firebaseApp );
@@ -1977,7 +1984,7 @@ private void promiseWithAuthResult(AuthResult authResult, Promise promise) {
19771984 if (authResult .getCredential () instanceof OAuthCredential ){
19781985 OAuthCredential creds = (OAuthCredential ) authResult .getCredential ();
19791986 WritableMap credentialMap = Arguments .createMap ();
1980-
1987+
19811988 credentialMap .putString ("providerId" , creds .getProvider ());
19821989 credentialMap .putString ("signInMethod" , creds .getSignInMethod ());
19831990
@@ -2037,15 +2044,23 @@ private void promiseWithAuthResult(AuthResult authResult, Promise promise) {
20372044 */
20382045 private void promiseRejectAuthException (Promise promise , Exception exception ) {
20392046 WritableMap error = getJSError (exception );
2040-
2047+
20412048 final String sessionId = error .getString ("sessionId" );
20422049 final MultiFactorResolver multiFactorResolver = mCachedResolvers .get (sessionId );
20432050 WritableMap resolverAsMap = Arguments .createMap ();
2051+
2052+ WritableMap map = Arguments .createMap ();
20442053 if (multiFactorResolver != null ) {
20452054 resolverAsMap = resolverToMap (sessionId , multiFactorResolver );
2055+ map .putMap ("resolver" , resolverAsMap );
20462056 }
2047- rejectPromiseWithCodeAndMessage (
2048- promise , error .getString ("code" ), error .getString ("message" ), resolverAsMap );
2057+
2058+ if (error .getString ("email" ) != null ){
2059+ map .putString ("email" , error .getString ("email" ));
2060+ }
2061+
2062+ rejectPromiseWithMap (
2063+ promise , error .getString ("code" ), error .getString ("message" ), map );
20492064 }
20502065
20512066 /**
@@ -2060,7 +2075,6 @@ private WritableMap getJSError(Exception exception) {
20602075 String invalidEmail = "The email address is badly formatted." ;
20612076
20622077 System .out .print (exception );
2063-
20642078 try {
20652079 FirebaseAuthException authException = (FirebaseAuthException ) exception ;
20662080 code = authException .getErrorCode ();
@@ -2096,7 +2110,7 @@ private WritableMap getJSError(Exception exception) {
20962110 + " before retrying this request." ;
20972111 break ;
20982112 case "ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL" :
2099- message =
2113+ message =
21002114 "An account already exists with the same email address but different sign-in"
21012115 + " credentials. Sign in using a provider associated with this email address." ;
21022116 break ;
@@ -2134,6 +2148,10 @@ private WritableMap getJSError(Exception exception) {
21342148 }
21352149 }
21362150
2151+ if (exception instanceof FirebaseAuthUserCollisionException ) {
2152+ error .putString ("email" , ((FirebaseAuthUserCollisionException ) exception ).getEmail ());
2153+ }
2154+
21372155 if (exception instanceof FirebaseAuthMultiFactorException ) {
21382156 final FirebaseAuthMultiFactorException multiFactorException =
21392157 (FirebaseAuthMultiFactorException ) exception ;
0 commit comments