keyword admin page

This commit is contained in:
PxlLoewe
2025-03-26 00:12:22 -07:00
parent 2b1fd83a97
commit 9551202370
9 changed files with 361 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import { prisma } from "@repo/db";
import { Error } from "_components/Error";
import { getServerSession } from "api/auth/[...nextauth]/auth";
export default async ({ children }: { children: React.ReactNode }) => {
const session = await getServerSession();
if (!session) return <Error title="Nicht eingeloggt" statusCode={401} />;
const user = await prisma.user.findUnique({
where: {
id: session.user.id,
},
});
if (!user?.permissions.includes("ADMIN_STATION"))
return <Error title="Keine Berechtigung" statusCode={403} />;
return <>{children}</>;
};