feat(auth): use the cookie session and refresh on 401

The token is no longer stored; a tbp_session flag remembers the
login. apiFetch renews the session once on a 401 and sends the
request again. Parallel requests and other tabs share one refresh,
because Auth revokes the session when a refresh token is used twice.
Only a 401 from the refresh ends the session; a 502 or no network
shows the normal error.
This commit is contained in:
lobo committed 2026-09-25 13:45:08 +02:00
1 parent 5ff8d48c53
commit d9a39dda22
34 files changed
+297 -147

No files matched your search

+2 -2
View File
@@ -20,7 +20,7 @@ import LibraryTabs from '../components/LibraryTabs.jsx';
import GameStatusBadge from '../components/GameStatusBadge.jsx';
import PageContainer from '../components/PageContainer.jsx';
import {apiFetch} from '../utils/api.js';
import {getToken} from '../utils/auth.js';
import {hasSession} from '../utils/auth.js';
const PAGE_SIZES = [20, 40, 80];
const DEFAULT_SIZE = 20;
@@ -60,7 +60,7 @@ export default function GameLibrary() {
const [error, setError] = useState(null);
const load = useCallback(async () => {
if (!getToken()) {
if (!hasSession()) {
navigate('/login');
return;
}