| 38 | // ownership on delete by id. Failures (not found OR org mismatch) both surface |
| 39 | // as Forbidden so we don't leak existence of ids outside the caller's org. |
| 40 | const assertDomainInSessionOrg = (domainId: string) => |
| 41 | Effect.gen(function* () { |
| 42 | const auth = yield* AuthContext; |
| 43 | const workos = yield* WorkOSClient; |
| 44 | const domain = yield* workos |
| 45 | .getOrganizationDomain(domainId) |
| 46 | .pipe(Effect.catchCause(() => Effect.succeed(null))); |
| 47 | if (!domain || domain.organizationId !== auth.organizationId) { |
| 48 | return yield* new Forbidden(); |
| 49 | } |
| 50 | }); |
| 51 | |
| 52 | export const OrgHandlers = HttpApiBuilder.group(OrgHttpApi, "org", (handlers) => |
| 53 | handlers |