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

Function activeOrg

e2e/cloud/support/session.ts:172–186  ·  view source on GitHub ↗
(
  target: TargetShape,
  identity: Identity,
)

Source from the content-addressed store, hash-verified

170
171/** The org this identity's session is currently bound to: id and URL slug. */
172export const activeOrg = (
173 target: TargetShape,
174 identity: Identity,
175): Effect.Effect<{ readonly id: string; readonly slug: string }> =>
176 Effect.promise(async () => {
177 const response = await fetch(new URL("/api/auth/me", target.baseUrl), {
178 headers: { cookie: cookieOf(identity) },
179 });
180 if (!response.ok) throw new Error(`/api/auth/me failed (${response.status})`);
181 const body = (await response.json()) as {
182 organization: { id: string; slug: string } | null;
183 };
184 if (!body.organization) throw new Error("identity has no active organization");
185 return { id: body.organization.id, slug: body.organization.slug };
186 });
187
188/** Every org this account is a member of, plus the one the session is on. */
189export const organizationsOf = (

Callers 1

Calls 3

cookieOfFunction · 0.70
jsonMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected