Fix misleading auth token storage in sessionStorage
- Remove JWT token and expires_at from sessionStorage - Simplify AuthProvider to use boolean isAuthenticated flag - Persist only isAuthenticated boolean for page-reload continuity - Update AuthProvider test to verify new auth model - Add comprehensive auth documentation to Web-Development.md explaining: - Cookie-based authentication model - How frontend auth state persists - Why tokens are no longer stored - Error handling flow for 401/403 responses The authentication model is cookie-based: the backend sets bangui_session cookie on login, frontend automatically includes it via credentials: 'include', and the backend is the sole authority on session validity. Previously stored tokens were never actually used and made the auth model misleading during development. Fixes TASK-STATE-04. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,23 +1,3 @@
|
||||
### TASK-STATE-03 — `DashboardFilterBar` Has Dual State Source
|
||||
|
||||
**Where found**
|
||||
`frontend/src/components/DashboardFilterBar.tsx`. The component reads from both `DashboardFilterProvider` context and from props using `??` as a fallback. `HistoryPage` passes filter values via props without mounting a `DashboardFilterProvider`, so the context values are `undefined` and the `??` fallback silently provides context defaults. `DashboardPage` uses context, so props are `undefined` and context values apply. Both pages render the same component but through different code paths.
|
||||
|
||||
**Goal**
|
||||
Choose one data source and use it consistently. The recommended approach is to use props everywhere: `DashboardPage` should read from context via `useDashboardFilter()` and pass the values explicitly to `DashboardFilterBar` as props, exactly like `HistoryPage` does. This makes the component's behaviour predictable — it always reads from props, never from context.
|
||||
|
||||
**Possible traps and issues**
|
||||
- `DashboardFilterProvider` may be used by other components on the dashboard. Audit all consumers of `useDashboardFilter()` before removing the context read from `DashboardFilterBar`.
|
||||
- The `??` fallback chain must be fully removed; otherwise the dual-source behaviour can creep back.
|
||||
|
||||
**Docs changes needed**
|
||||
None required.
|
||||
|
||||
**Why this is needed**
|
||||
Silent dual-source components are a debugging hazard. A developer adding a new consumer of `DashboardFilterBar` has no obvious signal about which data source is active, leading to subtle bugs when one source overrides the other.
|
||||
|
||||
---
|
||||
|
||||
### TASK-STATE-04 — Token in `sessionStorage` Is Never Sent (Misleading Auth Model)
|
||||
|
||||
**Where found**
|
||||
|
||||
Reference in New Issue
Block a user