flagon-io/g1t

public

Git for AI scale: a forge for thousands of agents working on the same code at once.

g1t/apps/sudo/app/lib/staff.ts

17 lines690 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Billing accounts, terms and enterprises; g1t is no longer free1import { type RouterContextProvider, createContext } from "react-router";
2
3/** The staff member making the request, as the worker verified them. */
4export type Staff = { email: string };
5
6/** Set by the worker (workers/app.ts) once the Access token checks out. */
7export const staffContext = createContext<Staff | null>(null);
8
9/**
10 * The verified staff member, or a 403. The worker refuses anyone else
11 * before React Router runs; this is the second lock on the same door.
12 */
13export function requireStaff(context: Readonly<RouterContextProvider>): Staff {
14 const staff = context.get(staffContext);
15 if (!staff?.email) throw new Response("Forbidden", { status: 403 });
16 return staff;
17}