Skip to content

Commit

Permalink
fix(auth, android): handle failure to upgrade anonymous user
Browse files Browse the repository at this point in the history
This is related to a #4487 - attempting to re-login with credential
after anonymous user signs in with apple sign-in on android
  • Loading branch information
mikehardy committed Nov 16, 2020
1 parent 8ead604 commit 41fad36
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1314,13 +1314,18 @@ private void linkWithCredential(
if (exception instanceof FirebaseAuthUserCollisionException) {
FirebaseAuthUserCollisionException authUserCollisionException = (FirebaseAuthUserCollisionException) exception;
AuthCredential updatedCredential = authUserCollisionException.getUpdatedCredential();
firebaseAuth.signInWithCredential(updatedCredential).addOnCompleteListener(getExecutor(), result -> {
if (result.isSuccessful()) {
promiseWithAuthResult(result.getResult(), promise);
} else {
promiseRejectAuthException(promise, exception);
}
});
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);
}
Expand Down

0 comments on commit 41fad36

Please sign in to comment.