feat: verschlüsselte Integrationseinstellungen, Haushaltsmitglieder mit Ersteller, Backup-Download

This commit is contained in:
opencode committed 2026-10-18 14:19:03 +02:00
1 parent a1195223e0
commit 267f4fcf70
21 files changed
+724 -30

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { NextRequest, NextResponse } from "next/server";
import {
getIntegrationStatus,
saveIntegrationSection,
validateIntegrationSection,
type IntegrationSection,
} from "@/lib/integration-settings";
import { canEncrypt } from "@/lib/settings-crypto";
export async function GET() {
return NextResponse.json(await getIntegrationStatus());
}
export async function POST(req: NextRequest) {
const body = await req.json().catch(() => ({}));
const section = String(body.section ?? "");
const values = (body.values ?? {}) as Record<string, unknown>;
const errs = validateIntegrationSection(section, values);
if (errs.length) return NextResponse.json({ errors: errs }, { status: 400 });
const stringValues: Record<string, string> = {};
for (const [k, v] of Object.entries(values)) {
if (typeof v === "string") stringValues[k] = v;
}
const needsEncryption = Object.entries(stringValues).some(
([k, v]) => v !== "" && (k === "smtp_pass" || k === "telegram_bot_token" || k === "logo_dev_secret_key")
);
if (needsEncryption && !canEncrypt()) {
return NextResponse.json(
{ errors: ["verschluesselung"], message: "SETTINGS_ENCRYPTION_KEY fehlt (min. 32 Zeichen in .env)" },
{ status: 503 }
);
}
const saved = await saveIntegrationSection(section as IntegrationSection, stringValues);
return NextResponse.json({ ok: true, saved, status: await getIntegrationStatus() });
}