MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / isOrgMember

Function isOrgMember

server/src/routes/certification.ts:25–37  ·  view source on GitHub ↗

* Check if a user belongs to an organization. * In dev mode, checks local DB. In production, calls WorkOS API.

(userId: string, orgId: string)

Source from the content-addressed store, hash-verified

23 * In dev mode, checks local DB. In production, calls WorkOS API.
24 */
25async function isOrgMember(userId: string, orgId: string): Promise<boolean> {
26 if (isDevModeEnabled()) {
27 const result = await query<{ count: string }>(
28 `SELECT COUNT(*)::text AS count FROM organization_memberships
29 WHERE workos_user_id = $1 AND workos_organization_id = $2`,
30 [userId, orgId]
31 );
32 return parseInt(result.rows[0]?.count || '0') > 0;
33 }
34 if (!workos) return false;
35 const memberships = await workos.userManagement.listOrganizationMemberships({ userId, organizationId: orgId });
36 return memberships.data.length > 0;
37}
38
39/**
40 * Create certification routes.

Callers 1

Calls 1

isDevModeEnabledFunction · 0.70

Tested by

no test coverage detected