Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.6 kB ยท 52 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { eq } from "@openstatus/db";import { workspace } from "@openstatus/db/src/schema";
import { emitAudit } from "../audit";import { requireScope } from "../auth";import { type ServiceContext, withTransaction } from "../context";import { NotFoundError } from "../errors";import { requireOwner } from "./internal";import { DisableSsoInput } from "./schemas";
/** * Turn SSO off for the workspace. Deliberately leaves `usersToWorkspaces` * untouched โ this is a configuration change, not deprovisioning, and members * keep access through GitHub / Google. */export async function disableSso(args: { ctx: ServiceContext; input?: DisableSsoInput;}): Promise<void> { const { ctx } = args; requireScope(ctx, "write"); const input = DisableSsoInput.parse(args.input ?? {});
await withTransaction(ctx, async (tx) => { await requireOwner(tx, ctx);
const existing = await tx .select() .from(workspace) .where(eq(workspace.id, ctx.workspace.id)) .get(); if (!existing) throw new NotFoundError("workspace", ctx.workspace.id);
if (!existing.ssoEnabled) return;
const updated = await tx .update(workspace) .set({ ssoEnabled: false, updatedAt: new Date() }) .where(eq(workspace.id, ctx.workspace.id)) .returning() .get();
await emitAudit(tx, ctx, { action: "workspace_sso.update", entityType: "workspace_sso", entityId: ctx.workspace.id, before: existing, after: updated, ...(input.reason ? { metadata: { reason: input.reason } } : {}), }); });}