mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-02 21:03:34 +03:00
# Description of Changes Refactor frontend auth to the shared folder and hook it up to both the portal and editor so they share the same system. Also adds various tasks to help run the portal, including `task dev:portal` to spawn the portal with the backend, and `task dev:portal:proxy` to spawn the editor, portal and backend, and a reverse proxy (at localhost:3000) to allow you to use both at once to simulate how this will actually be deployed, allowing you to check whether the seamless transition between the two actually works.
26 lines
749 B
TypeScript
26 lines
749 B
TypeScript
/**
|
|
* 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);
|
|
}
|