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