(userId: string, organizationId: string)
| 79 | // 403). |
| 80 | |
| 81 | export const authorizeOrganization = (userId: string, organizationId: string) => |
| 82 | Effect.gen(function* () { |
| 83 | const workos = yield* WorkOSClient; |
| 84 | const memberships = yield* workos.listUserMemberships(userId); |
| 85 | const active = memberships.data.find( |
| 86 | (m: { readonly organizationId: string; readonly status: string }) => |
| 87 | m.organizationId === organizationId && m.status === "active", |
| 88 | ); |
| 89 | if (!active) return null; |
| 90 | |
| 91 | return yield* resolveOrganization(organizationId); |
| 92 | }); |
| 93 | |
| 94 | // --------------------------------------------------------------------------- |
| 95 | // Org SELECTOR — the URL is the scope authority, not the session. |
no test coverage detected