Skip to content

[2.1] Fixes #28295: keep the deep link a signed-out user opened through login (backport 2.1 #38545) - #38578

Merged
sweta1308 merged 1 commit into
2.1from
backport/2.1/pr-38545
Nov 24, 2026
Merged

sweta1308 merged 1 commit into
2.1from
backport/2.1/pr-38545

Conversation

@sweta1308

Copy link
Copy Markdown
Contributor

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 on main (daad7f22a90), and it applied with no conflicts.

Why 2.1 needs it

2.1 contains b000856 (#34072), which made handleStoreProtectedRedirectPath read the current location through a ref. That opened the race this PR fixes. resumeSignedInSession on 2.1 reads the location only after await getOidcToken(), exactly as main did before #38545. So 2.1 intermittently sends a signed-out user who opened a deep link to / after sign-in.

2.0 does not need it. It does not contain #34072, and its handleStoreProtectedRedirectPath still closes over the location of the first render, which is the deep link.

What this PR changes

  • resumeSignedInSession captures the location before the await and passes it to handleStoreProtectedRedirectPath.
  • handleStoreProtectedRedirectPath takes an optional location and defaults to the current one. Its other caller, authCoordinator.install's onRefreshStart, calls it with no arguments and is unchanged.

Tests

  • src/components/Auth/AuthProviders/AuthProvider.test.tsx, run on this branch (base origin/2.1): 50 passed, 0 failed.
  • The new test, "stores the deep link an unauthenticated user opened even after the router has moved to /signin", fails against 2.1's unpatched AuthProvider.tsx (Number of calls: 0: the cookie is never written) and passes with this patch.
  • ESLint is clean on both files.
  • The browser evidence (25 runs on main vs the fix, plus screenshots) is in Fixes #28295: keep the deep link a signed-out user opened through login #38545.

🤖 Generated with Claude Code

…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)
@sweta1308
sweta1308 requested a review from a team as a code owner November 24, 2026 09:42
@sweta1308
sweta1308 requested review from karthicksharan and removed request for a team November 24, 2026 09:42
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@sweta1308 sweta1308 linked an issue Nov 24, 2026 that may be closed by this pull request
1 task done
@gitar-bot

gitar-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Capturing 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 2.1 by capturing the location in resumeSignedInSession before the await getOidcToken() and passing it to handleStoreProtectedRedirectPath, so users who open a deep link are returned to it after sign-in. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sweta1308
sweta1308 merged commit 578a5a0 into 2.1 Nov 24, 2026
47 of 49 checks passed
@sweta1308
sweta1308 deleted the backport/2.1/pr-38545 branch November 24, 2026 10:52
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.

Authentication always redirects users to the main page

2 participants