Skip to content

Implement "Phase 1" of anonymous user upgrade #1171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
samtstern opened this issue Feb 26, 2018 · 9 comments
Closed

Implement "Phase 1" of anonymous user upgrade #1171

samtstern opened this issue Feb 26, 2018 · 9 comments

Comments

@samtstern
Copy link
Contributor

This is related to #309 but because of the huge traffic / discussion over there I want to file a new clean issue about this piece.

For context this has already been release on Web and is coming in iOS:
https://github.com/firebase/firebaseui-web#upgrading-anonymous-users

This has two parts:

1 - New Flow Parameter

There will be a new boolean option to the intent builder, with the default as false:

AuthUI.getInstance()
        .createSignInIntentBuilder()
        // ...
        .setAutoUpgradeAnonymousAccounts(true)
        .build();

Throughout the flow, wherever we previously called signInWith... or signUpWith... we will now do the following logic (pseudocode):

if (hasAnonymousUser() && shouldAutoUpgrade) {
  linkAccount(...);
} else {
   signIn(...);
}

2 - Handling Link Failures

In the event that a link call fails, we will exit the flow with an error:

  • New error code ANONYMOUS_UPGRADE_MERGE_CONFLICT
  • The IdpResponse should contain the AuthCredential that we tried to link with but failed.
  • The User in the IdpResponse will be the anonymous user.

When handling the error, the developer should:

  • Read/cache the anonymous user data.
  • Sign in with the AuthCredential. They must make sure not to react to the auth state changed event.
  • Write the anonymous user cached data as appropriate to the new user.
  • Trigger their own sign-in success logic.

Notes

In a future "phase" of this feature we can do something similar to what @SUPERCILEX has already done and handle the complete flow including data transfer. In this "minimal" phase though this will only be for advanced developers that can handle the data transfer and display any relevant UI during that operation.

@atrepeklis
Copy link

Do you have a high level estimate on when this "Phase 1" will be released? I know we can always follow the SUPERCILEX approach but if we get it in a reasonable timeframe from the original source it might worth the wait.

@samtstern
Copy link
Contributor Author

@atrepeklis sorry I don't have a good estimate right now.

@samtstern samtstern self-assigned this Mar 13, 2018
@samtstern
Copy link
Contributor Author

@SUPERCILEX I am going to take a crack at this, using #309 as my guide.

@SUPERCILEX
Copy link
Collaborator

SUPERCILEX commented Mar 15, 2018

@samtstern Awesome! I'm going to crunch through my backlog tomorrow. 😊

@blueyetisoftware-jason
Copy link

@samtstern Do you have an active branch for this? Your approach above sounds simple and I was considering forking the repo to do this in my own app. I figured I would check for a branch here that may need a nudge to get it over the hump and approved instead of creating the fork.

@samtstern
Copy link
Contributor Author

@Phinatic no, my branch got crushed by all of our awesome stability refactors. It will never recover from the merge conflicts.

However @lsirac recently joined the project and is going to start working on this soon-ish.

@samtstern
Copy link
Contributor Author

See #1358

@samtstern
Copy link
Contributor Author

This has been released in version 4.1.0

@johanbx
Copy link

johanbx commented Jul 7, 2018

Should this not be .enableAnonymousUsersAutoUpgrade()? I find no reference for .setAutoUpgradeAnonymousAccounts(true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants