Skip to content

Commit 7cd1716

Browse files
authored
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
1 parent fbcd322 commit 7cd1716

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

packages/auth/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,30 +1214,7 @@ private void linkWithCredential(
12141214
} else {
12151215
Exception exception = task.getException();
12161216
Log.e(TAG, "link:onComplete:failure", exception);
1217-
if (exception instanceof FirebaseAuthUserCollisionException) {
1218-
FirebaseAuthUserCollisionException authUserCollisionException =
1219-
(FirebaseAuthUserCollisionException) exception;
1220-
AuthCredential updatedCredential =
1221-
authUserCollisionException.getUpdatedCredential();
1222-
try {
1223-
firebaseAuth
1224-
.signInWithCredential(updatedCredential)
1225-
.addOnCompleteListener(
1226-
getExecutor(),
1227-
result -> {
1228-
if (result.isSuccessful()) {
1229-
promiseWithAuthResult(result.getResult(), promise);
1230-
} else {
1231-
promiseRejectAuthException(promise, exception);
1232-
}
1233-
});
1234-
} catch (Exception e) {
1235-
// we the attempt to log in after the collision failed, reject back to JS
1236-
promiseRejectAuthException(promise, exception);
1237-
}
1238-
} else {
1239-
promiseRejectAuthException(promise, exception);
1240-
}
1217+
promiseRejectAuthException(promise, exception);
12411218
}
12421219
});
12431220
} else {

0 commit comments

Comments
 (0)