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:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user