Personal accounts
All checks were successful
Build and Push / build (push) Successful in 1m30s

This commit is contained in:
2026-04-26 22:26:33 +02:00
parent 2c85bf8597
commit 3521a0ff4f
14 changed files with 292 additions and 64 deletions

View File

@@ -10,6 +10,7 @@ import {
import { getTenant, listTenants } from "@/lib/k8s";
import { sendAdminNotificationEmail } from "@/lib/email";
import { encryptSecrets } from "@/lib/crypto";
import { isPersonalOrgName } from "@/lib/personal-org";
import type { OnboardingInput, PiecedTenant, TenantRequest } from "@/types";
import { z } from "zod";
@@ -176,6 +177,16 @@ export async function POST(request: Request) {
// company line in favour of the recorded company name.
const prior = await getMostRecentApprovedRequestForOrg(user.orgId);
// Slice 4: detect personal-account orgs by the canonical " (Personal)"
// suffix on the ZITADEL org name. Set at registration, stable for the
// lifetime of the org. Persisted on the row so admin views and the
// approve handler don't have to re-derive it.
//
// If any prior row has is_personal set, prefer that — it's the same
// org and the value can't change. (The prior-row check is defensive;
// the org-name check should agree.)
const isPersonal = prior?.isPersonal ?? isPersonalOrgName(user.orgName);
// Encrypt package secrets if provided
let encryptedSecrets: Buffer | undefined;
if (input.packageSecrets && Object.keys(input.packageSecrets).length > 0) {
@@ -212,6 +223,7 @@ export async function POST(request: Request) {
billingAddress,
billingNotes,
encryptedSecrets,
isPersonal,
});
// Notify admin about the new request. For follow-up instances, include