-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Description
The SignInIntentBuilder.enableAnonymousUsersAutoUpgrade() provides a configuration for linking credentials to an anonymous user. It would be nice to utilize this implementation to link credentials to authenticated users as well. This is especially useful for adding a phone number to an existing users or vise versa.
This might relate to #309.
Steps to reproduce:
- Start
AuthUIwith two providers (e.g. Google and Phone) - Sign in with Google
- Repeat 1.
- Sign in with Phone
Observed Results:
- A new user was created with the phone number provided in 4.
Expected Results:
- The phone number was added to the user signed in in 2.
Relevant Code:
From AuthOperationManager.java
public Task<AuthResult> signInAndLinkWithCredential(@NonNull FirebaseAuth auth,
@NonNull FlowParameters flowParameters,
@NonNull AuthCredential credential) {
if (canUpgradeAnonymous(auth, flowParameters)) {
return auth.getCurrentUser().linkWithCredential(credential);
} else {
return auth.signInWithCredential(credential);
}
}
public boolean canUpgradeAnonymous(FirebaseAuth auth, FlowParameters flowParameters) {
return flowParameters.isAnonymousUpgradeEnabled() && auth.getCurrentUser() != null &&
auth.getCurrentUser().isAnonymous();
}
RicardoBelchior, JoshuaBradbury, FanciROS and danijorda1