Repository navigation
fix(auth): finish email-link reauthentication when the link opens after a cold launch - #1430
Conversation
There was a problem hiding this comment.
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.
196e5b3 to
1e2afb8
Compare
1e2afb8 to
71c1520
Compare
71c1520 to
518defa
Compare
d94325a to
3bf4d24
Compare
9d86adf to
816eec9
Compare
…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.
816eec9 to
dfc84b3
Compare
… 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.
Finishes email-link reauthentication when the link opens the app after a cold launch, or while
EmailLinkReauthScreenisn't showing. Previously the link was dropped.Changes
AuthPickerContent'sonOpenURLcompletes a pending reauthentication throughhandleSignInLink(url:)when a user is signed in, read fromauth.currentUsersince the auth listener may not have run yet, and opens the sheet to show any error.EmailLinkReauthScreenmarks 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.testSignInErrorShowsOneAlertafter 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 afuidemo://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