fix admin save state architecture
This commit is contained in:
@@ -5,6 +5,7 @@ import { redirect } from "next/navigation";
|
||||
import { isRedirectError } from "next/dist/client/components/redirect";
|
||||
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { isCheckedFormValue } from "@/lib/form-data";
|
||||
import {
|
||||
getContactProtectionSettings,
|
||||
updateContactProtectionSettings,
|
||||
@@ -39,10 +40,10 @@ function parseContactProtectionFormData(
|
||||
formData: FormData,
|
||||
existingSettings: ContactProtectionSettings,
|
||||
): ContactProtectionSettings {
|
||||
const turnstileEnabled = formData.get("turnstileEnabled") === "on";
|
||||
const turnstileEnabled = isCheckedFormValue(formData.get("turnstileEnabled"));
|
||||
const turnstileSiteKey = String(formData.get("turnstileSiteKey") ?? "").trim();
|
||||
const turnstileSecretKey = String(formData.get("turnstileSecretKey") ?? "");
|
||||
const rateLimitEnabled = formData.get("contactRateLimitEnabled") === "on";
|
||||
const rateLimitEnabled = isCheckedFormValue(formData.get("contactRateLimitEnabled"));
|
||||
|
||||
if (turnstileEnabled && !turnstileSiteKey) {
|
||||
throw new Error("Turnstile site key is required when Turnstile is enabled.");
|
||||
|
||||
Reference in New Issue
Block a user