From a23382e2d081b9037323db26c4e6bd0f5df65652 Mon Sep 17 00:00:00 2001 From: potts99 Date: Mon, 27 Nov 2023 00:11:20 +0000 Subject: [PATCH] admin check --- apps/client/layouts/adminLayout.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/client/layouts/adminLayout.tsx b/apps/client/layouts/adminLayout.tsx index 38680cf05..01ab42a3f 100644 --- a/apps/client/layouts/adminLayout.tsx +++ b/apps/client/layouts/adminLayout.tsx @@ -1,6 +1,7 @@ import useTranslation from "next-translate/useTranslation"; import Link from "next/link"; import { useRouter } from "next/router"; +import { useUser } from "../store/session"; function classNames(...classes: any) { return classes.filter(Boolean).join(" "); @@ -10,7 +11,15 @@ export default function AdminLayout({ children }: any) { const { t, lang } = useTranslation("peppermint"); const router = useRouter(); - console.log("router.pathname", router.pathname); + const { user } = useUser(); + + if (user || user.role === "admin") { + return ( +
+

You are not an admin

+
+ ); + } const navigation = [ {