Skip to content

Commit

Permalink
bug(auth): fixed issue with apple sign-in on android
Browse files Browse the repository at this point in the history
This fixes an issue with Apple sign on Android. iOS was fixed with this commit. iOS was fixed with this PR invertase#4359. Note the solution is different. On iOS, it looks like we bubble the auth credentials back to js land and then retry login. Here, we attempt another login on auth collision errors
  • Loading branch information
nealmanaktola committed Oct 30, 2020
1 parent ee9edff commit 62d684f
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.FirebaseAuthProvider;
import com.google.firebase.auth.FirebaseAuthSettings;
import com.google.firebase.auth.FirebaseAuthUserCollisionException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.FirebaseUserMetadata;
import com.google.firebase.auth.GetTokenResult;
Expand Down Expand Up @@ -1303,9 +1304,20 @@ private void linkWithCredential(
} else {
Exception exception = task.getException();
Log.e(TAG, "link:onComplete:failure", exception);
promiseRejectAuthException(promise, exception);
}
});
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);
}
});
} else {
promiseRejectAuthException(promise, exception);
}
}});
} else {
promiseNoUser(promise, true);
}
Expand Down

0 comments on commit 62d684f

Please sign in to comment.