Skip to content

Commit

Permalink
admin check
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 27, 2023
1 parent 1b5fecd commit a23382e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/client/layouts/adminLayout.tsx
Original file line number Diff line number Diff line change
@@ -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(" ");
Expand All @@ -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 (
<div className="flex items-center justify-center h-screen">
<h1 className="text-4xl font-bold">You are not an admin</h1>
</div>
);
}

const navigation = [
{
Expand Down

0 comments on commit a23382e

Please sign in to comment.