Add dedicated local admin domain routing

This commit is contained in:
MOH
2026-03-13 17:48:45 +01:00
parent bfd7adccac
commit fef44ded80
47 changed files with 260 additions and 107 deletions
+6 -6
View File
@@ -4,7 +4,7 @@ import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
import { isRedirectError } from "next/dist/client/components/redirect-error";
import { toInternalAdminPath } from "@/lib/admin-routing";
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { isCheckedFormValue } from "@/lib/form-data";
import {
@@ -17,7 +17,7 @@ import type { MailSettings } from "@/lib/mail-settings";
async function ensureAdmin() {
if (!(await isAdminAuthenticated())) {
await clearAdminSessionCookie();
redirect("/");
redirect(getAdminAppPath("/"));
}
}
@@ -79,7 +79,7 @@ export async function saveMailSettingsAction(formData: FormData) {
await updateMailSettings(nextMailSettings);
revalidatePath(toInternalAdminPath("/smtp"));
redirect(withMessage("/smtp", "success", "SMTP Einstellungen gespeichert."));
redirect(withMessage(getAdminAppPath("/smtp"), "success", "SMTP Einstellungen gespeichert."));
} catch (error) {
if (isRedirectError(error)) {
throw error;
@@ -90,7 +90,7 @@ export async function saveMailSettingsAction(formData: FormData) {
? error.message
: "SMTP Einstellungen konnten nicht gespeichert werden.";
redirect(withMessage("/smtp", "error", message));
redirect(withMessage(getAdminAppPath("/smtp"), "error", message));
}
}
@@ -99,7 +99,7 @@ export async function sendTestEmailAction() {
try {
await sendTestEmail();
redirect(withMessage("/smtp", "success", "Test-E-Mail gesendet."));
redirect(withMessage(getAdminAppPath("/smtp"), "success", "Test-E-Mail gesendet."));
} catch (error) {
if (isRedirectError(error)) {
throw error;
@@ -110,6 +110,6 @@ export async function sendTestEmailAction() {
? error.message
: "Test-E-Mail konnte nicht gesendet werden.";
redirect(withMessage("/smtp", "error", message));
redirect(withMessage(getAdminAppPath("/smtp"), "error", message));
}
}
@@ -4,7 +4,7 @@ import { revalidatePath } from "next/cache";
import { redirect } from "next/navigation";
import { isRedirectError } from "next/dist/client/components/redirect-error";
import { toInternalAdminPath } from "@/lib/admin-routing";
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { isCheckedFormValue } from "@/lib/form-data";
import {
@@ -16,7 +16,7 @@ import type { ContactProtectionSettings } from "@/lib/contact-protection";
async function ensureAdmin() {
if (!(await isAdminAuthenticated())) {
await clearAdminSessionCookie();
redirect("/");
redirect(getAdminAppPath("/"));
}
}
@@ -92,7 +92,7 @@ export async function saveContactProtectionSettingsAction(formData: FormData) {
revalidatePath("/en/contact");
redirect(
withMessage(
"/smtp/contact-protection",
getAdminAppPath("/smtp/contact-protection"),
"success",
"Contact Protection gespeichert.",
),
@@ -107,6 +107,6 @@ export async function saveContactProtectionSettingsAction(formData: FormData) {
? error.message
: "Contact Protection konnte nicht gespeichert werden.";
redirect(withMessage("/smtp/contact-protection", "error", message));
redirect(withMessage(getAdminAppPath("/smtp/contact-protection"), "error", message));
}
}
+3 -2
View File
@@ -4,6 +4,7 @@ import { MotionFade } from "@/components/motion-fade";
import { ContactProtectionForm } from "@/components/admin/contact-protection-form";
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { getAdminAppPath } from "@/lib/admin-routing";
import { getContactProtectionFormValues } from "@/lib/app-config";
import { saveContactProtectionSettingsAction } from "./actions";
@@ -27,14 +28,14 @@ const copy = {
export default async function AdminSMTPProtectionPage() {
if (!(await isAdminAuthenticated())) {
redirect("/");
redirect(getAdminAppPath("/"));
}
async function logoutAction() {
"use server";
await clearAdminSessionCookie();
redirect("/");
redirect(getAdminAppPath("/"));
}
const settings = await getContactProtectionFormValues();
+3 -2
View File
@@ -5,6 +5,7 @@ import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
import { SMTPSettingsForm } from "@/components/admin/smtp-settings-form";
import { Button } from "@/components/ui/button";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { getAdminAppPath } from "@/lib/admin-routing";
import { getMailSettingsFormValues } from "@/lib/app-config";
import { saveMailSettingsAction, sendTestEmailAction } from "./actions";
@@ -28,14 +29,14 @@ const copy = {
export default async function AdminSMTPPage() {
if (!(await isAdminAuthenticated())) {
redirect("/");
redirect(getAdminAppPath("/"));
}
async function logoutAction() {
"use server";
await clearAdminSessionCookie();
redirect("/");
redirect(getAdminAppPath("/"));
}
const mailSettings = await getMailSettingsFormValues();