Conversation
…ther devices Keeps a single app link subscription so a second link is no longer dropped, persists the email and a session id so a link that launches the app completes sign in, asks the user to confirm their email when the link is opened on another device, and upgrades anonymous users instead of replacing them. BREAKING CHANGE: EmailLinkAuthListener gains onEmailRequired and EmailLinkAuthController gains confirmEmail, so classes implementing either must add them.
There was a problem hiding this comment.
Code Review
This pull request implements support for email link sign-in, enabling users to complete the authentication process even if the link is opened on a different device. Key changes include the introduction of session persistence using shared_preferences, updates to the UI flows to handle cross-device sign-in, and the addition of necessary localization strings. The reviewer identified several critical issues that need to be addressed, including invalid Dart syntax in map literals, a bug in the authentication instance handling that breaks multi-app support, and a logic flaw in link deduplication that prevents users from retrying the sign-in process.
…elated links Adds EmailLinkAuthProvider.upgradeAnonymousUsers (default false, as in FirebaseUI-Android) so anonymous users can still sign in to an existing account. Other deep links are only reported once a link was requested, a link that failed can be opened again, dispose no longer re-reads the launch link, and confirming a link from another device keeps this device's pending session.
EmailLinkSignInView showed the "link sent" message while signing in and the email form again after success, which was confusing when a link launched the app. It now shows a loading indicator while signing in and keeps the form hidden once sign in succeeded.
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.
Fixes #283.
Email link sign in now completes for a second link in the same session, for a link that launches the app after it was killed, and for a link opened on another device. Anonymous users can optionally be upgraded instead of replaced.
EmailLinkAuthListenergainsonEmailRequired(String link)andEmailLinkAuthControllergainsconfirmEmail(String email), so classes implementing either must add them. The custom widget example indocs/firebase-ui-auth/providers/email-link.mdshows both.Changes
EmailLinkAuthProviderkeeps a singleapp_linkssubscription. app_links closes its shared stream when the last listener cancels, which dropped the second link.shared_preferences, and the session id is added to the link (ui_sid,ui_auid, as in FirebaseUI-Android). The link that launched the app is read withgetInitialLink().EmailRequiredstate, andEmailLinkSignInViewasks the user to confirm their email. The view also shows a spinner while a link signs in instead of the "link sent" message.upgradeAnonymousUsersoption (off by default, as in FirebaseUI-Android) links the email to the current anonymous user withlinkWithCredential. That link must be opened on the same device.UserCreatedandCredentialLinkedalongsideSignedIn(🐛 Email signing-up (register) not responsive (a case uncovered by current documentation) #351). The example'sflutter_deeplinking_enabledflag moves onto the<activity>, where Flutter reads it.API Usage
Preview
Android emulators against the Auth emulator. Links are delivered with
adbbecause the Auth emulator does not send email.Link opens the app after it was killed
The app is swiped away after the link is sent. Opening the link launches it, shows a spinner while signing in, and lands on the profile.
email_link_cold_start.mp4
Link opened on another device
Left: the phone that requested the link. Right: a second phone with nothing stored, which asks the user to confirm their email.
email_link_other_device.mp4