AUTH-005 — Return users to the intended protected page after sign-in #96
Copy link
Copy link
Closed
Labels
area:authAuthentication and authorizationAuthentication and authorizationarea:webWeb application and hostingWeb application and hostingpriority:P1High-priority follow-upHigh-priority follow-upsize:SSmall focused issueSmall focused issuetype:featureProduct capabilityProduct capability
Description
Problem
Protected routes already send unauthenticated users to /login with state.from, but LoginForm ignores that state. After successful sign-in the user remains on the login page instead of returning to /account, a future /discounts page, or the admin route they requested.
Current evidence:
- src/pages/account/Account.tsx redirects with state.from.
- src/pages/admin/AdminGuard.tsx redirects with state.from.
- src/pages/login/LoginForm.jsx authenticates and only renders a welcome message.
Outcome
After successful sign-in, return the user to the intended safe internal route, with /account as the fallback.
Scope
- Read the router return destination from location state.
- Accept only a normalized same-app path beginning with one slash; reject protocol-relative, absolute, backslash, control-character, and malformed targets.
- Navigate with replace after successful sign-in.
- Default to /account when no safe target exists.
- Preserve current registration confirmation, password reset, error, and loading behavior.
- Add focused route-level tests.
Acceptance criteria
- Signing in after an /account redirect lands on /account.
- A safe internal target including query/hash is preserved.
- Missing or unsafe targets such as //example.com never leave the MPRC origin and fall back to /account.
- Failed sign-in stays on /login and shows the existing generic error.
- Registration behavior remains unchanged.
- Focused tests and the relevant frontend suite/build pass.
Dependencies and coordination
- Parent: COMMUNITY-EPIC — Unified member access and community integrations #79
- Unblocks the protected-route UX required by MEMBERS-CONTENT-001 — Build the Firebase-native members-only discounts page #83.
- No dependency on the parallel SAFETY-001, SEC-001, or PAY-003 file changes.
- Do not begin until assigned and a timestamped CLAIMED comment names the agent and branch.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:authAuthentication and authorizationAuthentication and authorizationarea:webWeb application and hostingWeb application and hostingpriority:P1High-priority follow-upHigh-priority follow-upsize:SSmall focused issueSmall focused issuetype:featureProduct capabilityProduct capability
Activity
daliu commentedon Jul 12, 2026
CLAIMED by Codex agent /root at 2026-07-12T20:16:35Z; branch codex/issue-96-login-return
daliu commentedon Jul 12, 2026
Implementation is ready in PR #97 from claimed branch
codex/issue-96-login-return.Verification completed under Node 20:
git diff --check: passTwo independent reviews found normalization and real query/hash round-trip gaps; both were fixed and both reviewers approved the revised diff. The unrelated
App.test.jsx/TextEncoderbaseline remains owned by the parallel test-harness work.fix: return users to protected route after login (#96) (#97)
daliu commentedon Jul 12, 2026
COMPLETED by Codex agent /root.
Merged PR #97 as
d26e002after two independent agent approvals and green repository CI (PR run https://github.com/Run-MPRC/Run-MPRC.github.io/actions/runs/29207880990; post-merge run https://github.com/Run-MPRC/Run-MPRC.github.io/actions/runs/29207938313). The configured deploy run https://github.com/Run-MPRC/Run-MPRC.github.io/actions/runs/29207938320 succeeded, created gh-pages commitfc5a398with source messagedeploy: d26e002..., and the follow-on Pages deployment https://github.com/Run-MPRC/Run-MPRC.github.io/actions/runs/29207978372 succeeded.Verification: focused route/login suite 15/15, production build, Functions lint/tests, Firestore emulator rules 97/97, diff check, and normalized open-redirect attack cases all pass under Node 20.
Hosting caveat (separate from AUTH-005):
runmprc.comcurrently responds from Netlify with older bundlemain.365e0fe5.js, while the newly generated GitHub Pages artifact containsmain.c974ecde.js. The code outcome is complete and the configured Pages deployment succeeded, but CI-001/WEB-001 must reconcile the production host/DNS before anyone claims this exact bundle is live at the canonical domain.