Files
Stirling-PDF/frontend/shared/auth/context.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
749 B
TypeScript
Raw Normal View History

2026-06-22 17:22:36 +01:00
/**
* The single React context backing `useAuth()`. Both the Spring and Supabase
* providers write to this same context so consumers read a unified value
* regardless of which backend authenticated the user.
*/
import { createContext, useContext } from "react";
import type { AuthContextValue } from "@shared/auth/types";
export const AuthContext = createContext<AuthContextValue>({
session: null,
user: null,
displayName: null,
isAnonymous: false,
isAdmin: false,
role: null,
loading: true,
error: null,
signOut: async () => {},
refreshSession: async () => {},
});
/** Access the current auth state. Must be used within an AuthProvider. */
export function useAuth(): AuthContextValue {
return useContext(AuthContext);
}