(userId: string, organizationId: string)
| 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. |
| 202 | const 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. */ |
| 218 | export const AUTHORIZE_ORGANIZATION_SPAN = "auth.authorize_organization"; |
no test coverage detected