fix(frontend): logout state not shown after JWT expires #40

Merged
dylan merged 2 commits from fix/no-logout-state-after-token-expire into master 2026-09-06 23:26:07 +01:00
Owner

This PR addresses the issue where an expired session token would leave the frontend stuck showing the user as logged in, causing raw JSON parsing errors on authenticated pages like "My VoDs" instead of gracefully logging the user out.

The core fix centralizes API request handling in client.ts through new apiFetch/apiFetchRaw helpers that consistently attach credentials and detect 401/403 responses. When an unauthorized response is detected, a globally registered handler is triggered, which AuthProvider uses to reset the user state and refresh authentication status. All API modules (clips, vods, markers, media, stream, users, jobs) were refactored to route through these shared helpers instead of duplicating raw fetch logic, so auth failures are now handled the same way everywhere.

As a result, expired or invalid sessions are now detected consistently across the app, the UI immediately reflects the logged-out state.

Resolves #21

This PR addresses the issue where an expired session token would leave the frontend stuck showing the user as logged in, causing raw JSON parsing errors on authenticated pages like "My VoDs" instead of gracefully logging the user out. The core fix centralizes API request handling in `client.ts` through new `apiFetch/apiFetchRaw` helpers that consistently attach credentials and detect 401/403 responses. When an unauthorized response is detected, a globally registered handler is triggered, which `AuthProvider` uses to reset the user state and refresh authentication status. All API modules (clips, vods, markers, media, stream, users, jobs) were refactored to route through these shared helpers instead of duplicating raw fetch logic, so auth failures are now handled the same way everywhere. As a result, expired or invalid sessions are now detected consistently across the app, the UI immediately reflects the logged-out state. Resolves #21
dylan added 1 commit 2026-09-06 21:15:44 +01:00
add apiFetch that checks for logout
All checks were successful
CI / Maven unit tests (push) Successful in 14s
CI / Build and push images (push) Has been skipped
CI / Deploy to server (push) Has been skipped
529b4c7725
dylan added 1 commit 2026-09-06 23:23:26 +01:00
add apiFetch to each endpoint and redirect to a non-auth required page
All checks were successful
CI / Maven unit tests (push) Successful in 15s
CI / Build and push images (push) Has been skipped
CI / Deploy to server (push) Has been skipped
ceb89882b1
dylan changed title from WIP: fix(frontend): logout state not shown after JWT expires to fix(frontend): logout state not shown after JWT expires 2026-09-06 23:25:31 +01:00
dylan merged commit 9758bb296b into master 2026-09-06 23:26:07 +01:00
dylan deleted branch fix/no-logout-state-after-token-expire 2026-09-06 23:26:08 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dylan/vod-system#40