Skip to content

Commit

Permalink
fix: Admin ui accessible by normal user (#1854)
Browse files Browse the repository at this point in the history
Its just a cosmetic change. All relevant data is protected by the API with roles
  • Loading branch information
sashko9807 authored Jun 19, 2024
1 parent 72c3d8a commit a4ccc0c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/common/navigation/AdminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import Link from 'next/link'
import { routes } from 'common/routes'
import PictureLogo from '/public/android-chrome-192x192.png'
import Image from 'next/image'
import { useSession } from 'next-auth/react'
import { isAdmin } from 'common/util/roles'

import NotFoundPage from '../errors/NotFoundPage/NotFoundPage'

const PREFIX = 'AdminLayout'
const drawerWidth = 200
Expand Down Expand Up @@ -97,7 +101,10 @@ type Props = {

export default function AdminLayout({ children }: Props) {
const theme = useTheme()

const session = useSession()
if (!isAdmin(session.data)) {
return <NotFoundPage />
}
const initialOpen = useMemo<boolean>(() => {
const item = typeof window !== 'undefined' ? window.localStorage.getItem('menu-open') : false
if (item) {
Expand Down

0 comments on commit a4ccc0c

Please sign in to comment.