Dough Git

clove/pkviewer

web/src/routes/admin/+layout.server.ts

back to web/src/routes/admin

/* web/src/routes/admin/+layout.server.ts */
import { error, redirect } from "@sveltejs/kit";
import type { LayoutServerLoad } from "./$types";
import { isAuthenticated, isPlatformAdmin } from "$lib/server/api.ts";

/**
 * A non-admin gets 404, not 403: 403 would confirm an admin area exists here.
 * A courtesy only; every /admin API route re-checks the platform grant.
 */
export const load: LayoutServerLoad = async () => {
  if (!(await isAuthenticated())) redirect(303, "/login?return_to=/admin");
  if (!(await isPlatformAdmin())) error(404);
};