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
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:
Outcome
After successful sign-in, return the user to the intended safe internal route, with /account as the fallback.
Scope
Acceptance criteria
Dependencies and coordination