FirebaseUI-Android icon indicating copy to clipboard operation
FirebaseUI-Android copied to clipboard

Provide FlowParameters for linking credentials to authenticated users

Open tynn opened this issue 4 years ago • 6 comments

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:

  1. Start AuthUI with two providers (e.g. Google and Phone)
  2. Sign in with Google
  3. Repeat 1.
  4. 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();
}

tynn avatar Aug 03 '20 21:08 tynn

Hi, thanks for the feature request! I've added this to our internal tracking (b/162980103).

sam-gc avatar Aug 05 '20 23:08 sam-gc

Hello @sam-gc, Have you any news about this feature ? Best Regards,

FanciROS avatar Dec 03 '21 17:12 FanciROS

Hi @FanciROS, unfortunately no updates for now

sam-gc avatar Dec 03 '21 17:12 sam-gc

Hi, any update on this? I'd be great to use Auth UI flow for Linking accounts via linkWithCredential

danijorda1 avatar Dec 31 '21 13:12 danijorda1

I saw this is already solved here 309 @samtstern seems this issue has been resolved perfectly great by @SUPERCILEX and still not avialble officially. Wouldn't it make sense to make the improvement avialble ? Even if IOS version is not alligned with this feature it doesn't make sense to hold the feature any longer for android users, specially since this has been avialble since 2017 or even before. Having the feature avialable will also encourage IOS team to deliver the feature sooner.... otherwise we will be waiting and waiting for an already avialble feature that is super helpful and mostly needed. Thanks in advance @samtstern , and also thanks a lot @SUPERCILEX for developing this super useful feature!

danijorda1 avatar Jan 05 '22 10:01 danijorda1

@sam-gc do you have rights to proceed, and resolve the conflicts in 309 and merge the pull request ? 309 is the solution for this. Thanks!

danijorda1 avatar Jan 05 '22 10:01 danijorda1