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