Refactor isAuthenticated check to use Boolean for clarity
This commit is contained in:
parent
7d0a6e5a74
commit
a30cfe1a1e
@ -2,7 +2,7 @@ import { GuardFunction } from "@/graphql/context/types";
|
|||||||
|
|
||||||
const initGuard: GuardFunction = auth => {
|
const initGuard: GuardFunction = auth => {
|
||||||
return {
|
return {
|
||||||
isAuthenticated: !!auth?.accessToken,
|
isAuthenticated: Boolean(auth?.accessToken),
|
||||||
hasRole: (roleName: string) => {
|
hasRole: (roleName: string) => {
|
||||||
return Array.isArray(auth?.roles) && auth.roles.some(r => r.name === roleName);
|
return Array.isArray(auth?.roles) && auth.roles.some(r => r.name === roleName);
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user