fix super user check
This commit is contained in:
parent
8b92a780bf
commit
80f9b43022
2 changed files with 5 additions and 2 deletions
|
@ -7,9 +7,11 @@ import { setGlobal } from '../femtoApp.ts'
|
|||
export interface User {
|
||||
id: string
|
||||
username: string
|
||||
roles: string[]
|
||||
roles: Role[]
|
||||
}
|
||||
|
||||
type Role = 'User' | 'SuperUser'
|
||||
|
||||
let globalUser: User | null
|
||||
|
||||
export function initUser() {
|
||||
|
|
|
@ -6,10 +6,11 @@ type NavBarProps = unknown
|
|||
|
||||
export default function NavBar({ children }: PropsWithChildren<NavBarProps>) {
|
||||
const user = useUser()
|
||||
const isSuperUser = user?.roles.includes('SuperUser')
|
||||
return (
|
||||
<nav className={`w-full flex flex-row justify-end gap-4 px-4 md:px-8 py-3`}>
|
||||
{children}
|
||||
{user?.isSuperUser && <NavButton to={'/admin/codes'}>admin</NavButton>}
|
||||
{isSuperUser && <NavButton to={'/admin/codes'}>admin</NavButton>}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue