Open
Conversation
Owner
|
Thanks for the pull request! As I understand this is still only usable for signInWithCredentials right? |
Author
|
Correct, it's only usable with signInWithCredentials. Unfortunately, the issue I mentioned with FirebaseAuthOAuth is not simple to solve. In my testing, both Twitter and Apple did not throw an exception to indicate that there is already an existing account. And the package returns the User already signed-in, not the credentials to sign in, so it's impossible to do linking and merging outside the package. I ended up implementing my own auth solution so that I can appropriately link and merge accounts, utilizing the individual libraries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR resolves #16
If a user is already logged in, lit tries to link the credential to their account. Thus, anonymous users can upgrade to a non-anonymous account. If that credential is already associated with an account, lit will call the
LinkMergeConflictCallback(if non-null) to resolve the merge conflict. The developer is responsible for merging data (from Firestore, Realtime Database, etc) within that callback, using thecredentialForLinkingto sign-in as the new user and migrate the data.Note, there is a bug with the FirebaseAuthOAuth plugin where no exception is thrown when there is already an existing account. I've created an issue in that repo to address it. Unfortunately, that means that account merging only works for sign in methods that use
FirebaseAuthFacade.signInWithCredential(). Once that issue is resolved, we can simply catch the exception and returnAuth.failure(AuthFailure.linkMergeConflict(e.credential)). I'm hoping the credential will be in the exception, but if not I'm not sure how to handle that.