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

Function AuthGate

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

useAuthFunction · 0.90

Tested by

no test coverage detected