Aktueller Stand
This commit is contained in:
@@ -4,9 +4,15 @@ import { prisma } from "../../../../lib/prisma";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET() {
|
||||
const setting = await prisma.setting.findUnique({
|
||||
where: { key: "registration_enabled" }
|
||||
const settings = await prisma.setting.findMany({
|
||||
where: { key: { in: ["registration_enabled", "email_verification_required"] } }
|
||||
});
|
||||
const map = new Map(settings.map((record) => [record.key, record.value]));
|
||||
const registrationEnabled = map.get("registration_enabled") !== "false";
|
||||
const emailVerificationRequired =
|
||||
map.get("email_verification_required") !== "false";
|
||||
return NextResponse.json({
|
||||
registrationEnabled,
|
||||
emailVerificationRequired
|
||||
});
|
||||
const registrationEnabled = setting?.value !== "false";
|
||||
return NextResponse.json({ registrationEnabled });
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ export async function POST(request: Request) {
|
||||
apiKey,
|
||||
provider,
|
||||
registrationEnabled,
|
||||
publicAccessEnabled
|
||||
publicAccessEnabled,
|
||||
emailVerificationRequired
|
||||
} = body || {};
|
||||
|
||||
if (!provider || !["google", "osm"].includes(provider)) {
|
||||
@@ -59,6 +60,14 @@ export async function POST(request: Request) {
|
||||
create: { key: "registration_enabled", value: registrationValue }
|
||||
});
|
||||
|
||||
const verificationValue =
|
||||
emailVerificationRequired === false ? "false" : "true";
|
||||
await prisma.setting.upsert({
|
||||
where: { key: "email_verification_required" },
|
||||
update: { value: verificationValue },
|
||||
create: { key: "email_verification_required", value: verificationValue }
|
||||
});
|
||||
|
||||
const existing = await getSystemSettings();
|
||||
const nextPublicAccessEnabled =
|
||||
typeof publicAccessEnabled === "boolean"
|
||||
@@ -79,6 +88,7 @@ export async function POST(request: Request) {
|
||||
apiKey: apiKeySetting.value,
|
||||
provider: providerSetting.value,
|
||||
registrationEnabled: registrationValue !== "false",
|
||||
publicAccessEnabled: nextPublicAccessEnabled
|
||||
publicAccessEnabled: nextPublicAccessEnabled,
|
||||
emailVerificationRequired: verificationValue !== "false"
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user