mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 18:11:16 +01:00
Protected routes answered 403 both when there was no session and when the authenticated user lacked the required scope. The frontend read every 403 as session expiry, cleared the session cookie and redirected to /login, so a permission denial (for instance saving a state without the save scope) tore down whatever the user was doing, including a running emulator. `protected_route` now uses its own scope guard that raises 401 with a `WWW-Authenticate` header when the caller is unauthenticated, and 403 when the caller is authenticated but under-scoped. The axios interceptor only redirects on 401 and lets 403s surface inline to the caller, refreshing the CSRF cookie when the backend rejected the CSRF token. Endpoint assertions for unauthenticated requests move from 403 to 401; authenticated under-scoped cases stay 403. Fixes #4045