Skip to content

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

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions