@@ -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 {
|
||||
@@ -16,7 +17,7 @@ import type { MailSettings } from "@/lib/mail-settings";
|
||||
function ensureAdmin() {
|
||||
if (!isAdminAuthenticated()) {
|
||||
clearAdminSessionCookie();
|
||||
redirect("/root");
|
||||
redirect("/");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +78,8 @@ export async function saveMailSettingsAction(formData: FormData) {
|
||||
const nextMailSettings = parseMailSettingsFormData(formData, existingMailSettings);
|
||||
|
||||
await updateMailSettings(nextMailSettings);
|
||||
revalidatePath("/root/smtp");
|
||||
redirect(withMessage("/root/smtp", "success", "SMTP Einstellungen gespeichert."));
|
||||
revalidatePath(toInternalAdminPath("/smtp"));
|
||||
redirect(withMessage("/smtp", "success", "SMTP Einstellungen gespeichert."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
@@ -89,7 +90,7 @@ export async function saveMailSettingsAction(formData: FormData) {
|
||||
? error.message
|
||||
: "SMTP Einstellungen konnten nicht gespeichert werden.";
|
||||
|
||||
redirect(withMessage("/root/smtp", "error", message));
|
||||
redirect(withMessage("/smtp", "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ export async function sendTestEmailAction() {
|
||||
|
||||
try {
|
||||
await sendTestEmail();
|
||||
redirect(withMessage("/root/smtp", "success", "Test-E-Mail gesendet."));
|
||||
redirect(withMessage("/smtp", "success", "Test-E-Mail gesendet."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
@@ -109,6 +110,6 @@ export async function sendTestEmailAction() {
|
||||
? error.message
|
||||
: "Test-E-Mail konnte nicht gesendet werden.";
|
||||
|
||||
redirect(withMessage("/root/smtp", "error", message));
|
||||
redirect(withMessage("/smtp", "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -28,14 +28,14 @@ const copy = {
|
||||
|
||||
export default async function RootSMTPPage() {
|
||||
if (!isAdminAuthenticated()) {
|
||||
redirect("/root");
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
clearAdminSessionCookie();
|
||||
redirect("/root");
|
||||
redirect("/");
|
||||
}
|
||||
|
||||
const mailSettings = await getMailSettingsFormValues();
|
||||
|
||||
Reference in New Issue
Block a user