Refactor isAuthenticated check to use Boolean for clarity

This commit is contained in:
Alexandre Bove 2025-08-01 08:51:42 +02:00
parent 7d0a6e5a74
commit a30cfe1a1e

View File

@ -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);
}, },