AZ-006 — Login and protected navigation

Status

Done

Context

Read README. AZ-002 provides registry/access metadata, responsive shell and a real preferences Settings page. AZ-005 provides cookie/CSRF login/logout/me and user provisioning. The frontend transport is the sole networking boundary; TanStack Query owns server state. Settings must now become authenticated deliberately; Home/message stay public to preserve the original slice.

Goal

Deliver mobile login/logout and correct protected-route/session behavior without stale-user data or credentials in browser storage.

Requirements

Non-goals

No account editing/recovery yet, self-registration, role authorization, external provider widgets, persisted bearer tokens, generic auth state machine, multi-tab synchronization platform or private ordering workflow.

Implementation guidance

Extend registry/router/providers/API modules and existing RTL renderApp, with injected controlled HTTP for frontend integration tests. Use MUI input labels/helper text, proper alert/status regions and route-heading focus. Keep session mutation retries off; Query's default read retry is not a reason to retry login/logout automatically. No raw fetch or status checks in page components. Use stable app/provider instances to prevent current-user requests on every render.

Acceptance criteria

Verification

pnpm quality
pnpm --filter @foodtruck-order/frontend test
pnpm --filter @foodtruck-order/frontend test:coverage
pnpm build
pnpm validate:docker

RTL tests cover guards/navigation, unsafe return URLs, failure/rate-limit/focus and cache races; Playwright proves the real mobile/desktop session journeys. Manually test 320/360px, tablet, desktop, phone virtual keyboard, password autofill, 200% zoom, Escape/focus and back navigation. Check protected-route refresh through nginx SPA fallback. Hosted same-site cookie behavior needs its own target evidence when release is authorized; do not claim it from localhost.

Documentation

Update development (login/provisioning/return routes, protected page registration), architecture (auth/query/cache ownership), testing (real auth fixtures and races), current-state/handover. Update Docker/CI if fixture lifecycle changes; never introduce hosted credentials in test jobs.

Dependencies

AZ-005 and its predecessors; app registry/theme/preferences and error conventions already exist.