Repository navigation
[2.1] Fixes #28295: keep the deep link a signed-out user opened through login (backport 2.1 #38545) - #38578
Conversation
…in (#38545) * Fixes #28295: keep the deep link a signed-out user opened through login resumeSignedInSession read the location only after awaiting getOidcToken. With no stored token, initializeAuthState clears isAuthenticating first, so the router can redirect the protected URL to /signin before that await returns; the location then read is /signin, nothing is stored, and the user lands on / after login. Capture the location before the await. * Restore the deep-link test's mocks even when its assertion fails * Type the deep-link test's location mock instead of disabling no-explicit-any (cherry picked from commit daad7f2)
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Code Review ✅ Approved 🟡 Medium riskCapturing the original route before token retrieval changes login redirects; regressions could send signed-out users to the home page instead of their deep link. Backports the signed-out deep link fix to VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Issue
Cherry-pick of #38545 to
2.1(Fixes #28295). The change is identical: the backport has the same patch id as the merged commit onmain(daad7f22a90), and it applied with no conflicts.Why 2.1 needs it
2.1contains b000856 (#34072), which madehandleStoreProtectedRedirectPathread the current location through a ref. That opened the race this PR fixes.resumeSignedInSessionon2.1reads the location only afterawait getOidcToken(), exactly asmaindid before #38545. So 2.1 intermittently sends a signed-out user who opened a deep link to/after sign-in.2.0does not need it. It does not contain #34072, and itshandleStoreProtectedRedirectPathstill closes over the location of the first render, which is the deep link.What this PR changes
resumeSignedInSessioncaptures the location before theawaitand passes it tohandleStoreProtectedRedirectPath.handleStoreProtectedRedirectPathtakes an optional location and defaults to the current one. Its other caller,authCoordinator.install'sonRefreshStart, calls it with no arguments and is unchanged.Tests
src/components/Auth/AuthProviders/AuthProvider.test.tsx, run on this branch (baseorigin/2.1): 50 passed, 0 failed.2.1's unpatchedAuthProvider.tsx(Number of calls: 0: the cookie is never written) and passes with this patch.mainvs the fix, plus screenshots) is in Fixes #28295: keep the deep link a signed-out user opened through login #38545.🤖 Generated with Claude Code