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

Function heldOrResolvedForMember

apps/cloud/src/auth/organization.ts:202–215  ·  view source on GitHub ↗
(userId: string, organizationId: string)

Source from the content-addressed store, hash-verified

200// does not hold it — only for a caller WorkOS confirms as its member (see
201// above). `null` when the mirror has no row and WorkOS lists no membership.
202const heldOrResolvedForMember = (userId: string, organizationId: string) =>
203 Effect.gen(function* () {
204 const users = yield* UserStoreService;
205 const held = yield* users.use("getOrganization", (s) => s.getOrganization(organizationId));
206 if (held) return held;
207 const workos = yield* WorkOSClient;
208 const membership = yield* workos.getUserOrgMembership(organizationId, userId);
209 if (!membership) return null;
210 yield* Effect.logInfo(
211 "authorizeOrganization: organization not mirrored; resolving it from WorkOS for its member",
212 { organizationId },
213 );
214 return yield* resolveOrganization(organizationId);
215 });
216
217/** The span every membership authorization runs under. */
218export const AUTHORIZE_ORGANIZATION_SPAN = "auth.authorize_organization";

Callers 1

authorizeOrganizationFunction · 0.85

Calls 1

resolveOrganizationFunction · 0.70

Tested by

no test coverage detected