Repository navigation
fix(auth): forget email-link reauthentication when it is cancelled or no user is signed in - #1431
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces state cleanup for email-link reauthentication when the process is cancelled, dismissed, or when there is no longer a signed-in user. It adds cancellation handlers in AuthService and the corresponding SwiftUI views, along with integration tests to verify the new behavior. The feedback suggests renaming the helper method hasPendingEmailLinkReauth() to checkAndCleanPendingEmailLinkReauth() (and updating its callsites) to better reflect its side-effects, adhering to the Command-Query Separation principle and Swift API Design Guidelines.
dd53050 to
c9bbb50
Compare
d9d1cd9 to
98cc6ed
Compare
98cc6ed to
cf2a54d
Compare
cf2a54d to
c28f09d
Compare
8ff1816 to
96cf8cd
Compare
russellwheatley
left a comment
There was a problem hiding this comment.
The README line added in #1430 is out of date with this change: "AuthPickerView also completes it when the link opens the app after the sheet closed, for example after a cold launch." Closing the sheet (Cancel or swipe) now forgets the reauth state, so a link opened afterwards takes the sign-in path, and presentEmailLinkScreen bails because the user is signed in. The only case left is the app being killed with the sheet still up, since onDisappear never runs then. Could you reword it in this PR to just cover that? Something like "...when the app was closed while the sheet was showing and the link reopens it."
… no user is signed in Cancelling or dismissing EmailLinkReauthView left the stored reauthentication state set, so later sign-in links were skipped by the email-link screen and routed to reauthentication. Clear that state when the view closes, cancel the coordinator when the sheet is swiped away, and drop leftover state when no user is signed in.
Forget the reauthentication a send stores after the view has closed, only cancel the coordinator on swipe-dismiss when no new request has started, and ignore leftover reauthentication without a signed-in user instead of clearing it, so a user that can't be read yet doesn't lose a pending one.
96cf8cd to
b36041a
Compare
…pp closed mid-reauth
|
@russellwheatley Reworded in c5f57f6 to cover only the app being closed while the reauth sheet is showing. The retry sentence still holds, since nothing resumes the original action after a relaunch. |
Clears stored email-link reauthentication state when it is abandoned, so later sign-in links are handled as sign-in again. Stacked on #1430.
Changes
EmailLinkReauthViewforgets the stored reauth email and flag, including when the close lands while the email is still sending. Before, the email-link screen skipped sign-in links andhandleSignInLink(url:)routed them to reauthentication.auth.currentUser, which is set beforecurrentUserafter a cold launch.Preview
Recorded on an erased simulator in the e2e example app (
--test-view-enabled), which signs out throughAuthon relaunch, so the session ends withoutsignOut(). Delete Account was patched locally to require a recent login, since the Auth emulator never does. Steps: sign in with an email link, Delete Account, cancel reauthentication, relaunch, then open a sign-in link for another user.Before (#1430,
518defa19e)Expected: when a user wants to sign in with an email link after a cancelled reauthentication, opening the link should sign them in.
pr1431-before.mp4
After (#1431,
98cc6ed8e0)pr1431-after.mp4