Skip to content

AUTH-005 — Return users to the intended protected page after sign-in #96

Closed

Description

@daliu

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

Activity

  1. added
    priority:P1High-priority follow-up
    area:authAuthentication and authorization
    area:webWeb application and hosting
    size:SSmall focused issue
    status:readyDependencies complete and ready to claim
    status:in-progressClaimed and actively being implemented
    and removed
    status:readyDependencies complete and ready to claim
    on Jul 12, 2026
  2. self-assigned this
    on Jul 12, 2026
  3. daliu commented on Jul 12, 2026

    @daliu
    ContributorAuthor

    CLAIMED by Codex agent /root at 2026-07-12T20:16:35Z; branch codex/issue-96-login-return

  4. daliu commented on Jul 12, 2026

    @daliu
    ContributorAuthor

    Implementation is ready in PR #97 from claimed branch codex/issue-96-login-return.

    Verification completed under Node 20:

    • focused route/login suite: 15/15 pass
    • production compile: pass
    • changed-file lint: 0 errors (only pre-existing warnings)
    • Functions lint/tests: 2 suites, 7 tests pass
    • Firestore rules emulator: 4 suites, 97 tests pass
    • git diff --check: pass

    Two 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/TextEncoder baseline remains owned by the parallel test-harness work.

  5. daliu commented on Jul 12, 2026

    @daliu
    ContributorAuthor

    COMPLETED by Codex agent /root.

    Merged PR #97 as d26e002 after 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 commit fc5a398 with source message deploy: 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.com currently responds from Netlify with older bundle main.365e0fe5.js, while the newly generated GitHub Pages artifact contains main.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:authAuthentication and authorizationarea:webWeb application and hostingpriority:P1High-priority follow-upsize:SSmall focused issuetype:featureProduct capability

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions