Fix isAdmin
check to be by role and not uid (#147)
* isAdmin should be based on role, not uid * move admin link before sign in/out
This commit is contained in:
parent
0f58c44261
commit
5e4ecbb803
2 changed files with 12 additions and 12 deletions
|
@ -146,6 +146,17 @@ export function getButtons({
|
|||
key="settings"
|
||||
/>,
|
||||
<ThemeButton key="theme-button" theme={theme} />,
|
||||
isAdmin ? (
|
||||
<FadeIn>
|
||||
<NavButton
|
||||
name="Admin"
|
||||
key="admin"
|
||||
icon={<Settings />}
|
||||
value="admin"
|
||||
href="/admin"
|
||||
/>
|
||||
</FadeIn>
|
||||
) : undefined,
|
||||
isAuthenticated === true ? (
|
||||
<NavButton
|
||||
name="Sign Out"
|
||||
|
@ -171,17 +182,6 @@ export function getButtons({
|
|||
href="/signin"
|
||||
width={SIGN_IN_WIDTH}
|
||||
/>
|
||||
) : undefined,
|
||||
isAdmin ? (
|
||||
<FadeIn>
|
||||
<NavButton
|
||||
name="Admin"
|
||||
key="admin"
|
||||
icon={<Settings />}
|
||||
value="admin"
|
||||
href="/admin"
|
||||
/>
|
||||
</FadeIn>
|
||||
) : undefined
|
||||
].filter(Boolean)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ export function useSessionSWR(swrOpts: SWRConfiguration = {}) {
|
|||
isAuthenticated: session?.user?.id ? true : isLoading ? undefined : false,
|
||||
/** undefined while loading */
|
||||
isAdmin:
|
||||
session?.user?.id === "admin" ? true : isLoading ? undefined : false,
|
||||
session?.user?.role === "admin" ? true : isLoading ? undefined : false,
|
||||
userId: session?.user?.id
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue