Skip to content

Commit

Permalink
fix(auth, android): linkWithCredential will not attempt to upgrade fr…
Browse files Browse the repository at this point in the history
…om 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
  • Loading branch information
Albocal authored Sep 4, 2021
1 parent fbcd322 commit 7cd1716
Showing 1 changed file with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

1 comment on commit 7cd1716

@vercel
Copy link

@vercel vercel bot commented on 7cd1716 Sep 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.