@@ -3,7 +3,7 @@
|
||||
import { MediaUsageType, Prisma } from "@prisma/client";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
import { isRedirectError } from "next/dist/client/components/redirect";
|
||||
import { isRedirectError } from "next/dist/client/components/redirect-error";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
import { routing } from "@/i18n/routing";
|
||||
@@ -23,9 +23,9 @@ import {
|
||||
sectionInputSchema,
|
||||
} from "@/lib/portfolio-validation";
|
||||
|
||||
function ensureAdmin() {
|
||||
if (!isAdminAuthenticated()) {
|
||||
clearAdminSessionCookie();
|
||||
async function ensureAdmin() {
|
||||
if (!(await isAdminAuthenticated())) {
|
||||
await clearAdminSessionCookie();
|
||||
redirect("/");
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ async function removeManagedPaths(paths: string[]) {
|
||||
}
|
||||
|
||||
export async function upsertCategoryAction(formData: FormData) {
|
||||
ensureAdmin();
|
||||
await ensureAdmin();
|
||||
|
||||
const redirectPath = getRedirectPath(formData, "/portfolio/categories");
|
||||
|
||||
@@ -155,7 +155,7 @@ export async function upsertCategoryAction(formData: FormData) {
|
||||
}
|
||||
|
||||
export async function deleteCategoryAction(formData: FormData) {
|
||||
ensureAdmin();
|
||||
await ensureAdmin();
|
||||
|
||||
const redirectPath = getRedirectPath(formData, "/portfolio/categories");
|
||||
const id = String(formData.get("id") ?? "");
|
||||
@@ -189,7 +189,7 @@ export async function deleteCategoryAction(formData: FormData) {
|
||||
}
|
||||
|
||||
export async function saveProjectAction(formData: FormData) {
|
||||
ensureAdmin();
|
||||
await ensureAdmin();
|
||||
|
||||
const fallbackRedirect = String(formData.get("id") ?? "").trim()
|
||||
? `/portfolio/projects/${String(formData.get("id") ?? "").trim()}`
|
||||
@@ -564,7 +564,7 @@ export async function saveProjectAction(formData: FormData) {
|
||||
}
|
||||
|
||||
export async function deleteProjectAction(formData: FormData) {
|
||||
ensureAdmin();
|
||||
await ensureAdmin();
|
||||
|
||||
const id = String(formData.get("id") ?? "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user