(userId: string, organizationId: string)
| 67 | // 403). |
| 68 | |
| 69 | export const authorizeOrganization = (userId: string, organizationId: string) => |
| 70 | Effect.gen(function* () { |
| 71 | const workos = yield* WorkOSClient; |
| 72 | const memberships = yield* workos.listUserMemberships(userId); |
| 73 | const active = memberships.data.find( |
| 74 | (m: { readonly organizationId: string; readonly status: string }) => |
| 75 | m.organizationId === organizationId && m.status === "active", |
| 76 | ); |
| 77 | if (!active) return null; |
| 78 | |
| 79 | return yield* resolveOrganization(organizationId); |
| 80 | }); |
| 81 | |
| 82 | // --------------------------------------------------------------------------- |
| 83 | // Org SELECTOR — the URL is the scope authority, not the session. |
no test coverage detected