Skip to content

Commit

Permalink
only display special features to correct user
Browse files Browse the repository at this point in the history
  • Loading branch information
themrphantom committed Apr 29, 2024
1 parent 8d337e4 commit 9620bc0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend/src/Components/Common/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ const TopBar = (props: Props) => {
const [aboutDialogOpen, setaboutDialogOpen] = useState(false)

const showDrawerButton = () => {
return location.pathname.startsWith("/admin") || location.pathname.startsWith("/user")
if (location.pathname.startsWith("/admin")) {
return true
} else if (location.pathname.startsWith("/user")) {
const memberIDCookie = Cookies.get(window.globalTS.AUTH_COOKIE_PREFIX + "memberID")
const memberIDCookieSafe = memberIDCookie ? parseInt(memberIDCookie) : -1
const isAdmin = memberIDCookieSafe === 1
const isCorrectUser = location.pathname.endsWith(memberIDCookieSafe.toString())
if (isAdmin || isCorrectUser) {
return true
}
}
return false
}

useEffect(() => {
Expand Down

0 comments on commit 9620bc0

Please sign in to comment.