From 7cd1716c0adef0f390b34409e737ac14da8120a8 Mon Sep 17 00:00:00 2001 From: Albocal Date: Sat, 4 Sep 2021 16:42:04 +0200 Subject: [PATCH] fix(auth, android): linkWithCredential will not attempt to upgrade from anon user (matches iOS) (#5694) Description When doing "linkWithCredential" in Android and the users exists relogin with this new user instead of launch exception Error: [auth/credential-already-in-use] This credential is already associated with a different user account. Related PR #4487 and PR #4552 --- .../auth/ReactNativeFirebaseAuthModule.java | 25 +------------------ 1 file changed, 1 insertion(+), 24 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 6e670e37af..d6dcbc2951 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 @@ -1214,30 +1214,7 @@ private void linkWithCredential( } else { Exception exception = task.getException(); Log.e(TAG, "link:onComplete:failure", exception); - if (exception instanceof FirebaseAuthUserCollisionException) { - FirebaseAuthUserCollisionException authUserCollisionException = - (FirebaseAuthUserCollisionException) exception; - AuthCredential updatedCredential = - authUserCollisionException.getUpdatedCredential(); - try { - firebaseAuth - .signInWithCredential(updatedCredential) - .addOnCompleteListener( - getExecutor(), - result -> { - if (result.isSuccessful()) { - promiseWithAuthResult(result.getResult(), promise); - } else { - promiseRejectAuthException(promise, exception); - } - }); - } catch (Exception e) { - // we the attempt to log in after the collision failed, reject back to JS - promiseRejectAuthException(promise, exception); - } - } else { - promiseRejectAuthException(promise, exception); - } + promiseRejectAuthException(promise, exception); } }); } else {