MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / AuthGate

Function AuthGate

apps/host-cloudflare/web/routes/__root.tsx:43–59  ·  view source on GitHub ↗
({ children }: { children: ReactNode })

Source from the content-addressed store, hash-verified

41);
42
43function AuthGate({ children }: { children: ReactNode }) {
44 const auth = useAuth();
45
46 // Access already authenticated the user at the edge; an unauthenticated state
47 // means there's no live Access session (gate not configured, or expired) —
48 // send them through the Access login, which returns to the app with a JWT.
49 useEffect(() => {
50 if (auth.status === "unauthenticated") {
51 window.location.href = "/cdn-cgi/access/login";
52 }
53 }, [auth.status]);
54
55 if (auth.status === "authenticated") return <>{children}</>;
56 return (
57 <Loading label={auth.status === "unauthenticated" ? "Redirecting to sign in…" : "Loading…"} />
58 );
59}
60
61function AuthenticatedApp() {
62 const auth = useAuth();

Callers

nothing calls this directly

Calls 1

useAuthFunction · 0.90

Tested by

no test coverage detected