@@ -4,6 +4,7 @@ import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
import { isRedirectError } from "next/dist/client/components/redirect";
|
||||
|
||||
import { toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { isCheckedFormValue } from "@/lib/form-data";
|
||||
import {
|
||||
@@ -15,7 +16,7 @@ import type { ContactProtectionSettings } from "@/lib/contact-protection";
|
||||
function ensureAdmin() {
|
||||
if (!isAdminAuthenticated()) {
|
||||
clearAdminSessionCookie();
|
||||
redirect("/root");
|
||||
redirect("/");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,13 +86,13 @@ export async function saveContactProtectionSettingsAction(formData: FormData) {
|
||||
const nextSettings = parseContactProtectionFormData(formData, existingSettings);
|
||||
|
||||
await updateContactProtectionSettings(nextSettings);
|
||||
revalidatePath("/root/smtp/contact-protection");
|
||||
revalidatePath(toInternalAdminPath("/smtp/contact-protection"));
|
||||
revalidatePath("/contact");
|
||||
revalidatePath("/ar/contact");
|
||||
revalidatePath("/en/contact");
|
||||
redirect(
|
||||
withMessage(
|
||||
"/root/smtp/contact-protection",
|
||||
"/smtp/contact-protection",
|
||||
"success",
|
||||
"Contact Protection gespeichert.",
|
||||
),
|
||||
@@ -106,6 +107,6 @@ export async function saveContactProtectionSettingsAction(formData: FormData) {
|
||||
? error.message
|
||||
: "Contact Protection konnte nicht gespeichert werden.";
|
||||
|
||||
redirect(withMessage("/root/smtp/contact-protection", "error", message));
|
||||
redirect(withMessage("/smtp/contact-protection", "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ const copy = {
|
||||
|
||||
export default async function RootSMTPProtectionPage() {
|
||||
if (!isAdminAuthenticated()) {
|
||||
redirect("/root");
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
clearAdminSessionCookie();
|
||||
redirect("/root");
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
const settings = await getContactProtectionFormValues();
|
||||
|
||||
Reference in New Issue
Block a user