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"
|
key="settings"
|
||||||
/>,
|
/>,
|
||||||
<ThemeButton key="theme-button" theme={theme} />,
|
<ThemeButton key="theme-button" theme={theme} />,
|
||||||
|
isAdmin ? (
|
||||||
|
<FadeIn>
|
||||||
|
<NavButton
|
||||||
|
name="Admin"
|
||||||
|
key="admin"
|
||||||
|
icon={<Settings />}
|
||||||
|
value="admin"
|
||||||
|
href="/admin"
|
||||||
|
/>
|
||||||
|
</FadeIn>
|
||||||
|
) : undefined,
|
||||||
isAuthenticated === true ? (
|
isAuthenticated === true ? (
|
||||||
<NavButton
|
<NavButton
|
||||||
name="Sign Out"
|
name="Sign Out"
|
||||||
|
@ -171,17 +182,6 @@ export function getButtons({
|
||||||
href="/signin"
|
href="/signin"
|
||||||
width={SIGN_IN_WIDTH}
|
width={SIGN_IN_WIDTH}
|
||||||
/>
|
/>
|
||||||
) : undefined,
|
|
||||||
isAdmin ? (
|
|
||||||
<FadeIn>
|
|
||||||
<NavButton
|
|
||||||
name="Admin"
|
|
||||||
key="admin"
|
|
||||||
icon={<Settings />}
|
|
||||||
value="admin"
|
|
||||||
href="/admin"
|
|
||||||
/>
|
|
||||||
</FadeIn>
|
|
||||||
) : undefined
|
) : undefined
|
||||||
].filter(Boolean)
|
].filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ export function useSessionSWR(swrOpts: SWRConfiguration = {}) {
|
||||||
isAuthenticated: session?.user?.id ? true : isLoading ? undefined : false,
|
isAuthenticated: session?.user?.id ? true : isLoading ? undefined : false,
|
||||||
/** undefined while loading */
|
/** undefined while loading */
|
||||||
isAdmin:
|
isAdmin:
|
||||||
session?.user?.id === "admin" ? true : isLoading ? undefined : false,
|
session?.user?.role === "admin" ? true : isLoading ? undefined : false,
|
||||||
userId: session?.user?.id
|
userId: session?.user?.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue