Refactor authentication logic and API client

- Update AuthProvider with improved error handling and token management
- Enhance API client with better request/response handling
- Add comprehensive test coverage for auth flows
- Update documentation with current tasks

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-04-25 19:23:12 +02:00
parent 6a062a72a7
commit f84aeef249
5 changed files with 82 additions and 50 deletions

View File

@@ -25,7 +25,7 @@ import {
} from "react";
import { useNavigate } from "react-router-dom";
import * as authApi from "../api/auth";
import { SESSION_EXPIRED_EVENT } from "../api/client";
import { setUnauthorizedHandler } from "../api/client";
// ---------------------------------------------------------------------------
// Context
@@ -75,9 +75,11 @@ export function AuthProvider({
}, [navigate]);
useEffect((): (() => void) => {
window.addEventListener(SESSION_EXPIRED_EVENT, handleSessionExpired);
setUnauthorizedHandler((): void => {
handleSessionExpired();
});
return (): void => {
window.removeEventListener(SESSION_EXPIRED_EVENT, handleSessionExpired);
setUnauthorizedHandler(null);
};
}, [handleSessionExpired]);