Add dedicated local admin domain routing
This commit is contained in:
@@ -4,7 +4,7 @@ import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getLocalizedPath } from "@/lib/locale";
|
||||
import { setMaintenanceMode } from "@/lib/app-config";
|
||||
@@ -12,7 +12,7 @@ import { setMaintenanceMode } from "@/lib/app-config";
|
||||
async function ensureAdmin() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function updateMaintenanceModeAction(formData: FormData) {
|
||||
await ensureAdmin();
|
||||
|
||||
const nextValue = formData.get("enabled") === "true";
|
||||
const redirectPath = String(formData.get("redirectPath") ?? "/");
|
||||
const redirectPath = String(formData.get("redirectPath") ?? getAdminAppPath("/"));
|
||||
const redirectUrl = new URL(redirectPath, "http://localhost");
|
||||
redirectUrl.searchParams.set(
|
||||
"success",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { MotionFade } from "@/components/motion-fade";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getMaintenanceMode } from "@/lib/app-config";
|
||||
import { AppCard } from "@/components/ui/app-card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
@@ -31,7 +32,7 @@ export default async function AdminMaintenancePage() {
|
||||
const authenticated = await isAdminAuthenticated();
|
||||
|
||||
if (!authenticated) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const maintenanceEnabled = await getMaintenanceMode();
|
||||
@@ -39,7 +40,7 @@ export default async function AdminMaintenancePage() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -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 { updateMarqueeSettings } from "@/lib/app-config";
|
||||
import { routing } from "@/i18n/routing";
|
||||
@@ -13,7 +13,7 @@ import { getLocalizedPath } from "@/lib/locale";
|
||||
async function ensureAdmin() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ export async function saveMarqueeSettingsAction(formData: FormData) {
|
||||
await updateMarqueeSettings(settings);
|
||||
await revalidateMarqueePages();
|
||||
|
||||
redirect(withMessage("/marquee", "success", "Marquee gespeichert."));
|
||||
redirect(withMessage(getAdminAppPath("/marquee"), "success", "Marquee gespeichert."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const message = error instanceof Error ? error.message : "Marquee konnte nicht gespeichert werden.";
|
||||
redirect(withMessage("/marquee", "error", message));
|
||||
redirect(withMessage(getAdminAppPath("/marquee"), "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { MarqueeSettingsForm } from "@/components/admin/marquee-settings-form";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { MotionFade } from "@/components/motion-fade";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getMarqueeSettings } from "@/lib/app-config";
|
||||
|
||||
import { saveMarqueeSettingsAction } from "./actions";
|
||||
@@ -27,14 +28,14 @@ const copy = {
|
||||
|
||||
export default async function AdminMarqueePage() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const marqueeSettings = await getMarqueeSettings();
|
||||
|
||||
@@ -5,7 +5,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 { countMediaUsageReferences, getMediaAssetById } from "@/lib/media";
|
||||
import { createStandaloneMediaAsset, deleteMediaAssetAndFile } from "@/lib/media-service";
|
||||
@@ -15,7 +15,7 @@ import { prisma } from "@/lib/prisma";
|
||||
async function ensureAdmin() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,14 +47,14 @@ export async function createMediaAssetAction(formData: FormData) {
|
||||
});
|
||||
|
||||
revalidateMediaPages();
|
||||
redirect(withMessage("/media", "success", "Datei gespeichert."));
|
||||
redirect(withMessage(getAdminAppPath("/media"), "success", "Datei gespeichert."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const message = error instanceof Error ? error.message : "Datei konnte nicht gespeichert werden.";
|
||||
redirect(withMessage("/media", "error", message));
|
||||
redirect(withMessage(getAdminAppPath("/media"), "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ export async function deleteMediaAssetAction(formData: FormData) {
|
||||
const asset = await getMediaAssetById(assetId);
|
||||
|
||||
if (!asset) {
|
||||
redirect(withMessage("/media", "error", "Datei nicht gefunden."));
|
||||
redirect(withMessage(getAdminAppPath("/media"), "error", "Datei nicht gefunden."));
|
||||
}
|
||||
|
||||
const usageCount = await countMediaUsageReferences(asset.id);
|
||||
|
||||
if (usageCount > 0) {
|
||||
redirect(withMessage("/media", "error", "Datei wird noch verwendet."));
|
||||
redirect(withMessage(getAdminAppPath("/media"), "error", "Datei wird noch verwendet."));
|
||||
}
|
||||
|
||||
await prisma.mediaAsset.delete({
|
||||
@@ -90,13 +90,13 @@ export async function deleteMediaAssetAction(formData: FormData) {
|
||||
}
|
||||
|
||||
revalidateMediaPages();
|
||||
redirect(withMessage("/media", "success", "Datei geloescht."));
|
||||
redirect(withMessage(getAdminAppPath("/media"), "success", "Datei geloescht."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
const message = error instanceof Error ? error.message : "Datei konnte nicht geloescht werden.";
|
||||
redirect(withMessage("/media", "error", message));
|
||||
redirect(withMessage(getAdminAppPath("/media"), "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { MediaLibraryManager } from "@/components/admin/media-library-manager";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getAdminMediaAssets } from "@/lib/media";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -22,14 +23,14 @@ const copy = {
|
||||
|
||||
export default async function AdminMediaPage() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const mediaAssets = await getAdminMediaAssets();
|
||||
|
||||
+6
-5
@@ -20,6 +20,7 @@ import {
|
||||
resetAdminFailedAttempts,
|
||||
setAdminSessionCookie,
|
||||
} from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getMaintenanceMode } from "@/lib/app-config";
|
||||
import { getAdminMediaAssets } from "@/lib/media";
|
||||
import { getAdminPortfolioCategories, getAdminPortfolioProjects } from "@/lib/portfolio";
|
||||
@@ -76,28 +77,28 @@ export default async function AdminPage({ searchParams }: AdminPageProps) {
|
||||
const currentLockState = await getAdminLockState();
|
||||
|
||||
if (currentLockState.locked) {
|
||||
redirect("/?error=locked");
|
||||
redirect(`${getAdminAppPath("/")}?error=locked`);
|
||||
}
|
||||
|
||||
if (!isAdminAuthConfigured() || !isPasswordValid(password)) {
|
||||
const failState = await registerFailedAdminAttempt();
|
||||
if (failState.locked) {
|
||||
redirect("/?error=locked");
|
||||
redirect(`${getAdminAppPath("/")}?error=locked`);
|
||||
}
|
||||
|
||||
redirect("/?error=invalid");
|
||||
redirect(`${getAdminAppPath("/")}?error=invalid`);
|
||||
}
|
||||
|
||||
await resetAdminFailedAttempts();
|
||||
await setAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
if (!authenticated) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { isRedirectError } from "next/dist/client/components/redirect-error";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { deleteEntityMediaUsages, replaceEntityMediaUsages } from "@/lib/media";
|
||||
import { resolveMediaSelection } from "@/lib/media-service";
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
async function ensureAdmin() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ async function removeManagedPaths(paths: string[]) {
|
||||
export async function upsertCategoryAction(formData: FormData) {
|
||||
await ensureAdmin();
|
||||
|
||||
const redirectPath = getRedirectPath(formData, "/portfolio/categories");
|
||||
const redirectPath = getRedirectPath(formData, getAdminAppPath("/portfolio/categories"));
|
||||
|
||||
try {
|
||||
const parsed = categoryInputSchema.parse({
|
||||
@@ -157,7 +157,7 @@ export async function upsertCategoryAction(formData: FormData) {
|
||||
export async function deleteCategoryAction(formData: FormData) {
|
||||
await ensureAdmin();
|
||||
|
||||
const redirectPath = getRedirectPath(formData, "/portfolio/categories");
|
||||
const redirectPath = getRedirectPath(formData, getAdminAppPath("/portfolio/categories"));
|
||||
const id = String(formData.get("id") ?? "");
|
||||
|
||||
try {
|
||||
@@ -192,8 +192,8 @@ export async function saveProjectAction(formData: FormData) {
|
||||
await ensureAdmin();
|
||||
|
||||
const fallbackRedirect = String(formData.get("id") ?? "").trim()
|
||||
? `/portfolio/projects/${String(formData.get("id") ?? "").trim()}`
|
||||
: "/portfolio/projects/new";
|
||||
? getAdminAppPath(`/portfolio/projects/${String(formData.get("id") ?? "").trim()}`)
|
||||
: getAdminAppPath("/portfolio/projects/new");
|
||||
const redirectPath = getRedirectPath(formData, fallbackRedirect);
|
||||
const uploadedPaths: string[] = [];
|
||||
const createdMediaAssetIds: string[] = [];
|
||||
@@ -526,7 +526,7 @@ export async function saveProjectAction(formData: FormData) {
|
||||
}
|
||||
|
||||
redirect(
|
||||
withMessage(`/portfolio/projects/${projectResult.project.id}`, "success", "Projekt gespeichert."),
|
||||
withMessage(getAdminAppPath(`/portfolio/projects/${projectResult.project.id}`), "success", "Projekt gespeichert."),
|
||||
);
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
@@ -579,7 +579,7 @@ export async function deleteProjectAction(formData: FormData) {
|
||||
});
|
||||
|
||||
if (!project) {
|
||||
redirect(withMessage("/portfolio", "error", "Project not found."));
|
||||
redirect(withMessage(getAdminAppPath("/portfolio"), "error", "Project not found."));
|
||||
}
|
||||
|
||||
await prisma.portfolioProject.delete({
|
||||
@@ -596,12 +596,12 @@ export async function deleteProjectAction(formData: FormData) {
|
||||
revalidatePath(getLocalizedPath(locale, `/portfolio/${project.slug}`));
|
||||
}
|
||||
|
||||
redirect(withMessage("/portfolio", "success", "Project deleted."));
|
||||
redirect(withMessage(getAdminAppPath("/portfolio"), "success", "Project deleted."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
redirect(withMessage("/portfolio", "error", "Unable to delete project."));
|
||||
redirect(withMessage(getAdminAppPath("/portfolio"), "error", "Unable to delete project."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { PortfolioCategoriesManager } from "@/components/admin/portfolio-categories-manager";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getAdminPortfolioCategories } from "@/lib/portfolio";
|
||||
|
||||
import { deleteCategoryAction, upsertCategoryAction } from "../actions";
|
||||
@@ -24,14 +25,14 @@ const copy = {
|
||||
|
||||
export default async function AdminPortfolioCategoriesPage() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const categories = await getAdminPortfolioCategories();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
|
||||
export default function AdminPortfolioMediaRedirectPage() {
|
||||
redirect("/media");
|
||||
redirect(getAdminAppPath("/media"));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { PortfolioProjectsOverview } from "@/components/admin/portfolio-projects-overview";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getAdminPortfolioCategories, getAdminPortfolioProjects } from "@/lib/portfolio";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -33,14 +34,14 @@ export default async function AdminPortfolioPage({ searchParams }: AdminPortfoli
|
||||
const resolvedSearchParams = await searchParams;
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const selectedCategory = resolvedSearchParams?.category && resolvedSearchParams.category !== "__all__"
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getMediaOptions } from "@/lib/media";
|
||||
import {
|
||||
getActivePortfolioCategories,
|
||||
@@ -53,14 +54,14 @@ export default async function AdminPortfolioProjectPage({
|
||||
params,
|
||||
}: AdminPortfolioProjectPageProps) {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const { id } = await params;
|
||||
@@ -72,7 +73,7 @@ export default async function AdminPortfolioProjectPage({
|
||||
]);
|
||||
|
||||
if (!project) {
|
||||
redirect("/portfolio?error=Project+not+found.");
|
||||
redirect(`${getAdminAppPath("/portfolio")}?error=Project+not+found.`);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -92,7 +93,7 @@ export default async function AdminPortfolioProjectPage({
|
||||
mediaOptions={mediaOptions}
|
||||
project={project}
|
||||
formId="portfolio-project-form"
|
||||
redirectPath={`/portfolio/projects/${project.id}`}
|
||||
redirectPath={getAdminAppPath(`/portfolio/projects/${project.id}`)}
|
||||
/>
|
||||
</MotionFade>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { MotionFade } from "@/components/motion-fade";
|
||||
import { PortfolioProjectForm } from "@/components/admin/portfolio-project-form";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getMediaOptions } from "@/lib/media";
|
||||
import { getActivePortfolioCategories } from "@/lib/portfolio";
|
||||
|
||||
@@ -26,14 +27,14 @@ const copy = {
|
||||
|
||||
export default async function AdminNewPortfolioProjectPage() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const [categories, mediaOptions] = await Promise.all([
|
||||
@@ -57,7 +58,7 @@ export default async function AdminNewPortfolioProjectPage() {
|
||||
categories={categories}
|
||||
mediaOptions={mediaOptions}
|
||||
formId="portfolio-project-form"
|
||||
redirectPath="/portfolio/projects/new"
|
||||
redirectPath={getAdminAppPath("/portfolio/projects/new")}
|
||||
/>
|
||||
</MotionFade>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { PortfolioProjectsOverview } from "@/components/admin/portfolio-projects-overview";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { getAdminPortfolioCategories, getAdminPortfolioProjects } from "@/lib/portfolio";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -33,14 +34,14 @@ export default async function AdminPortfolioProjectsPage({
|
||||
const resolvedSearchParams = await searchParams;
|
||||
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const selectedCategory = resolvedSearchParams?.category && resolvedSearchParams.category !== "__all__"
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
SITE_SETTINGS_LOGO_LIGHT_FIELD_KEY,
|
||||
updateSiteSettings,
|
||||
} from "@/lib/app-config";
|
||||
import { toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
|
||||
import { PAGE_TITLE_TOKEN, type SiteSettings } from "@/lib/site-settings";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { replaceEntityMediaUsages } from "@/lib/media";
|
||||
@@ -28,7 +28,7 @@ import { prisma } from "@/lib/prisma";
|
||||
async function ensureAdmin() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ export async function saveSiteSettingsAction(formData: FormData) {
|
||||
});
|
||||
|
||||
await revalidateSiteSettingsPages();
|
||||
redirect(withMessage("/site-settings", "success", "Einstellungen gespeichert."));
|
||||
redirect(withMessage(getAdminAppPath("/site-settings"), "success", "Einstellungen gespeichert."));
|
||||
} catch (error) {
|
||||
if (isRedirectError(error)) {
|
||||
throw error;
|
||||
@@ -291,6 +291,6 @@ export async function saveSiteSettingsAction(formData: FormData) {
|
||||
? error.message
|
||||
: "Einstellungen konnten nicht gespeichert werden.";
|
||||
|
||||
redirect(withMessage("/site-settings", "error", message));
|
||||
redirect(withMessage(getAdminAppPath("/site-settings"), "error", message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { MotionFade } from "@/components/motion-fade";
|
||||
import { SiteSettingsForm } from "@/components/admin/site-settings-form";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import {
|
||||
getSiteSettings,
|
||||
getSiteSettingsMediaBindings,
|
||||
@@ -31,14 +32,14 @@ const copy = {
|
||||
|
||||
export default async function AdminSiteSettingsPage() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
const [siteSettings, mediaBindings, mediaOptions] = await Promise.all([
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
|
||||
import { MotionFade } from "@/components/motion-fade";
|
||||
import { AdminDashboardShell } from "@/components/admin/admin-dashboard-shell";
|
||||
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
|
||||
import { getAdminAppPath } from "@/lib/admin-routing";
|
||||
import { UiKitShowcase } from "@/components/ui/ui-kit-showcase";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -24,14 +25,14 @@ export default async function AdminUiKitPage() {
|
||||
const authenticated = await isAdminAuthenticated();
|
||||
|
||||
if (!authenticated) {
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
async function logoutAction() {
|
||||
"use server";
|
||||
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
redirect(getAdminAppPath("/"));
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,2 +1,19 @@
|
||||
export { metadata } from "../_admin/layout";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
robots: {
|
||||
index: false,
|
||||
follow: false,
|
||||
nocache: true,
|
||||
googleBot: {
|
||||
index: false,
|
||||
follow: false,
|
||||
noimageindex: true,
|
||||
"max-image-preview": "none",
|
||||
"max-snippet": -1,
|
||||
"max-video-preview": -1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export { default } from "../_admin/layout";
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { dynamic } from "../../_admin/maintenance/page";
|
||||
export const dynamic = "force-dynamic";
|
||||
export { default } from "../../_admin/maintenance/page";
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { dynamic } from "../../_admin/media/page";
|
||||
export const dynamic = "force-dynamic";
|
||||
export { default } from "../../_admin/media/page";
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { dynamic } from "../_admin/page";
|
||||
export const dynamic = "force-dynamic";
|
||||
export { default } from "../_admin/page";
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { Metadata } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
robots: {
|
||||
index: false,
|
||||
follow: false,
|
||||
nocache: true,
|
||||
googleBot: {
|
||||
index: false,
|
||||
follow: false,
|
||||
noimageindex: true,
|
||||
"max-image-preview": "none",
|
||||
"max-snippet": -1,
|
||||
"max-video-preview": -1,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export { default } from "../_admin/layout";
|
||||
@@ -0,0 +1,2 @@
|
||||
export const dynamic = "force-dynamic";
|
||||
export { default } from "../../_admin/maintenance/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../_admin/marquee/page";
|
||||
@@ -0,0 +1,2 @@
|
||||
export const dynamic = "force-dynamic";
|
||||
export { default } from "../../_admin/media/page";
|
||||
@@ -0,0 +1,2 @@
|
||||
export const dynamic = "force-dynamic";
|
||||
export { default } from "../_admin/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../../_admin/portfolio/categories/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../../_admin/portfolio/media/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../_admin/portfolio/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../../../_admin/portfolio/projects/[id]/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../../../_admin/portfolio/projects/new/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../../_admin/portfolio/projects/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../_admin/site-settings/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../../_admin/smtp/contact-protection/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../_admin/smtp/page";
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "../../_admin/ui-kit/page";
|
||||
Reference in New Issue
Block a user