Skip to content

Commit 0159ead

Browse files
committed
fix(auth, android): handle failure to upgrade anonymous user
This is related to a invertase#4487 - attempting to re-login with credential after anonymous user signs in with apple sign-in on android
1 parent d2a294b commit 0159ead

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

+12-7
Original file line numberDiff line numberDiff line change
@@ -1314,13 +1314,18 @@ private void linkWithCredential(
13141314
if (exception instanceof FirebaseAuthUserCollisionException) {
13151315
FirebaseAuthUserCollisionException authUserCollisionException = (FirebaseAuthUserCollisionException) exception;
13161316
AuthCredential updatedCredential = authUserCollisionException.getUpdatedCredential();
1317-
firebaseAuth.signInWithCredential(updatedCredential).addOnCompleteListener(getExecutor(), result -> {
1318-
if (result.isSuccessful()) {
1319-
promiseWithAuthResult(result.getResult(), promise);
1320-
} else {
1321-
promiseRejectAuthException(promise, exception);
1322-
}
1323-
});
1317+
try {
1318+
firebaseAuth.signInWithCredential(updatedCredential).addOnCompleteListener(getExecutor(), result -> {
1319+
if (result.isSuccessful()) {
1320+
promiseWithAuthResult(result.getResult(), promise);
1321+
} else {
1322+
promiseRejectAuthException(promise, exception);
1323+
}
1324+
});
1325+
} catch (Exception e) {
1326+
// we the attempt to log in after the collision failed, reject back to JS
1327+
promiseRejectAuthException(promise, exception);
1328+
}
13241329
} else {
13251330
promiseRejectAuthException(promise, exception);
13261331
}

0 commit comments

Comments
 (0)