Repository navigation
feat(auth): confirm the email when a sign-in link opens on another device - #1429
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the email link sign-in flow by adding support for cross-device sign-in, allowing users to confirm their email address when opening a link on a different device unless forceSameDevice is enabled. The changes include tracking pending links and session IDs in AuthService, updating the UI in EmailLinkScreen and DefaultEmailLinkContent to support the confirmation state, and adding comprehensive integration tests. The review feedback suggests several robust improvements: copying the shared ActionCodeSettings to prevent concurrent mutation issues, guarding against unrelated deep links early in handleSignInLink, and implementing a mechanism to clear the pending email link state when navigating away to prevent the UI from getting stuck in confirmation mode.
43994e1 to
e74d5a5
Compare
e74d5a5 to
2fef1b8
Compare
0325fa6 to
3036794
Compare
3036794 to
47eed83
Compare
9170a9f to
2aae885
Compare
…links The action-code builder replaced the continue URL's query items with ui_auid alone, dropping parameters the app put on it. Keep them and drop only the items the library writes, since the configured settings object is reused for every link.
…vice Restores the FirebaseUI-iOS v15 cross-device email-link flow. Links carry ui_sid and ui_sd; a link opened without this device's session asks the user to confirm their email through EmailLinkContentState.needsEmailConfirmation and confirmEmail, or is rejected when withEmailLinkSignIn(forceSameDevice: true) is set. AuthPickerView now opens the email-link screen for a link received while that screen isn't showing, and the continue URL is read before the link's second decode, which dropped every continue-URL parameter after the first.
A link waiting for email confirmation stayed pending after sign-out, a closed sheet or a used link, so the email-link screen kept asking for an email and never offered to send a new link. Clear it in those cases and add cancelEmailLinkConfirmation with a cancelConfirmation action on EmailLinkContentState. Also leave opened links to an app's own email-link screen, and stop treating a link without ui_sid as this device's once a newer link was sent.
A link opened on another device threw before this change, and apps may rely on that, so keep throwing invalidEmailLink while also setting pendingEmailLink; the stock screen shows the confirm step instead of the error. Ignore a link that is already being handled or already signed in, so AuthPickerView and an app's own onOpenURL handler don't both use the same one-time link.
A second handleSignInLink call with a link already being handled returned at once, so an app's own onOpenURL could treat a failed sign-in as done. It now waits for the first attempt and gets its result. EmailLinkScreen hides the cross-device error only for the link that set pendingEmailLink, and signing out forgets the last used link so tapping it again reports that it expired.
EmailLinkScreen and EmailLinkReauthScreen handled every URL the app opened, so an unrelated deep link opened while either showed an error. They now handle only Firebase email sign-in links. Leaving EmailLinkScreen also drops a link waiting for email confirmation, so returning to it offers to send a new link.
2aae885 to
49ec541
Compare
Restores v15's cross-device email-link sign-in: a link opened on a device that didn't request it asks for the email address instead of failing.
forceSameDevicekeeps links on the requesting device. Builds on #1428.Changes
ui_sidandui_sdas in v15, and keep the app's own continue-URL parameters instead of replacing them.EmailLinkContentStategainsneedsEmailConfirmation,confirmEmailandcancelConfirmation, with init defaults, and the stock screen shows a Confirm Email step.handleSignInLink(url:)still throws for such a link and also keeps it inpendingEmailLink; sign-out, closing the sheet or a used link clears it.AuthPickerViewopens the email-link screen when the app receives a link while that screen isn't showing, as after a cold launch or on another device. A call with a link already being handled waits for that attempt and gets its result, so apps' ownonOpenURLhandlers keep working.API Usage
Preview
Maintainer note: Fixes internal CPRN-640