Skip to content

fix(auth): finish email-link reauthentication when the link opens after a cold launch - #1430

Merged
demolaf merged 4 commits into
mainfrom
fix/email-link-reauth-cold-launch
Nov 17, 2026
Merged

demolaf merged 4 commits into
mainfrom
fix/email-link-reauth-cold-launch

Conversation

@demolaf

@demolaf demolaf commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Finishes email-link reauthentication when the link opens the app after a cold launch, or while EmailLinkReauthScreen isn't showing. Previously the link was dropped.

Changes

  • AuthPickerContent's onOpenURL completes a pending reauthentication through handleSignInLink(url:) when a user is signed in, read from auth.currentUser since the auth listener may not have run yet, and opens the sheet to show any error.
  • EmailLinkReauthScreen marks itself as showing, so the top-level handler leaves the link to it and the link isn't handled twice.
  • handleSignInLink(url:) gives a second call with a reauthentication link already in flight the first call's outcome, and ignores the link if it's delivered again after reauthentication finished.
  • Integration test against the Auth emulator covering the cold launch, the reauth view showing, and the same link delivered twice.
  • UI test text entry waits up to 10 seconds for a paste to land, and pastes again only if none arrived, since a slow CI simulator failed testSignInErrorShowsOneAlert after the text was already in the field.

Preview

Recorded in the e2e example app (--test-view-enabled) on an erased simulator, with a local demo patch: the app keeps its session across relaunch, Delete Account requires a sign-in within the last 20 seconds (the Auth emulator never asks for a recent login), and a fuidemo:// scheme opens the emulator's links. Steps: signed in with an email link, Delete Account, Send Verification Email, kill and relaunch the app, open the reauthentication link, then Delete Account again.

Before

Expected: when a user opens their reauthentication link after the app was closed, reauthentication should finish so Delete Account goes through.

before.mp4

After

after.mp4

Maintainer note: Fixes internal CPRN-652

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for completing email-link reauthentication when the app is opened via a deep link while the reauthentication view is not active, such as after a cold launch. The changes track the visibility of the reauthentication view, add a handler to process the link from the main entry point, and update integration tests. The review feedback identifies two critical issues: first, using the asynchronous currentUser property during a cold launch can cause the link to be silently dropped, so using the synchronous auth.currentUser is recommended; second, lastSignedInEmailLink should be updated upon successful reauthentication to prevent duplicate link deliveries from triggering unexpected errors.

@demolaf
demolaf marked this pull request as ready for review November 5, 2026 13:52
@demolaf
demolaf force-pushed the fix/email-link-reauth-cold-launch branch from 196e5b3 to 1e2afb8 Compare November 9, 2026 15:46
@demolaf
demolaf added this pull request to stack #1433 November 9, 2026 15:50
@demolaf
demolaf force-pushed the fix/email-link-reauth-cold-launch branch from 1e2afb8 to 71c1520 Compare November 10, 2026 14:30
@demolaf
demolaf force-pushed the fix/email-link-reauth-cold-launch branch from 71c1520 to 518defa Compare November 10, 2026 15:56
@demolaf
demolaf force-pushed the fix/email-link-reauth-cold-launch branch 2 times, most recently from d94325a to 3bf4d24 Compare November 13, 2026 14:14
@demolaf
demolaf force-pushed the fix/email-link-reauth-cold-launch branch 2 times, most recently from 9d86adf to 816eec9 Compare November 16, 2026 12:33
Base automatically changed from auth/email-link-same-device to main November 16, 2026 13:08
…er a cold launch

AuthPickerContent now completes reauthentication with a link the app opens while EmailLinkReauthView isn't showing, and leaves it to that view while it shows. A reauthentication link already in flight is ignored, so a link delivered to several onOpenURL handlers is used once.
…andled

EmailLinkReauthView no longer resumes the waiting action when a second tap of the link returns while the first is still in flight. The email-link tests reset stored reauthentication state before each test, and the README notes the user retries the action after a cold-launch reauthentication.
@demolaf
demolaf force-pushed the fix/email-link-reauth-cold-launch branch from 816eec9 to dfc84b3 Compare November 16, 2026 13:08
… or reused

finishEmailLinkReauthentication checked AuthService.currentUser, which the auth listener fills in after launch, so a link that opened the app could arrive before it and be dropped. It now checks auth.currentUser. A link delivered again after reauthentication finished was taken for a sign-in link and threw; it is now remembered like a used sign-in link.
On a busy CI simulator the pasted text can appear several seconds after the Paste tap, so enterText failed while the field already held the right value. Wait up to 10 seconds instead of 3, and paste once more only when none of the text has arrived.

@russellwheatley russellwheatley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@demolaf
demolaf merged commit 47b6804 into main Nov 17, 2026
21 checks passed
@demolaf
demolaf deleted the fix/email-link-reauth-cold-launch branch November 17, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants