Files
vod-system/frontend/src/auth/AuthContext.ts
Dylan De Faoite 4b4cc3145f
All checks were successful
CI / Maven unit tests (push) Successful in 23s
CI / Build and push images (push) Has been skipped
CI / Deploy to server (push) Has been skipped
fix frontend
2026-10-16 20:54:07 +01:00

21 lines
837 B
TypeScript

import { createContext } from "react";
import type { User } from "../utils/types.ts";
type AuthContextValue = {
/** The currently authenticated user, or null when logged out. */
user: User | null;
/** True until the initial "who am I" request has resolved. */
loading: boolean;
/** Exchange a Google credential for a session, then load the user. */
login: (googleCredential: string) => Promise<void>;
/** End the session and clear the user. The local session is cleared even if the server call fails. */
logout: () => Promise<void>;
/** Re-fetch the current user (e.g. after a profile change). Token refresh is handled automatically. */
refresh: () => Promise<void>;
};
const AuthContext = createContext<AuthContextValue | null>(null);
export { AuthContext };
export type { AuthContextValue };