From c5493722622bfbe6b35c0c610a689ee17ba2edfe Mon Sep 17 00:00:00 2001 From: Carter Date: Tue, 19 May 2026 16:06:48 -0600 Subject: [PATCH] added forgotten local auth file --- src/providers/authContext.tsx | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/providers/authContext.tsx diff --git a/src/providers/authContext.tsx b/src/providers/authContext.tsx new file mode 100644 index 0000000..cee441c --- /dev/null +++ b/src/providers/authContext.tsx @@ -0,0 +1,44 @@ +import { useAuth0 } from "@auth0/auth0-react" +import { createContext, PropsWithChildren, useContext } from "react" + +interface IAuthContext { + isAuthenticated: boolean + loginWithRedirect: () => void + logout: () => void +} + +const AuthContext = createContext({ + isAuthenticated: false, + loginWithRedirect: () => {}, + logout: () => {}, +}) + +export function LocalAuthProvider(props: PropsWithChildren<{ token: string }>) { + const { children, token } = props + const doLogout = () => { + localStorage.removeItem('local_auth_token') + window.location.href = '/' + } + return ( + + {children} + + ) +} + +export function Auth0AuthBridge(props: PropsWithChildren<{}>) { + const { isAuthenticated, loginWithRedirect, logout } = useAuth0() + return ( + logout({ logoutParams: { returnTo: window.location.origin } }) }}> + {props.children} + + ) +} + +export const useAuthContext = () => useContext(AuthContext)