import { rule } from 'nexus-plugin-shield' import { adminIsSignin, getRole, userIsSignin } from './utils/auth' import { Role } from './roles' export const isAuthenticated = rule()(async (parent, args, ctx) => { return userIsSignin(ctx) }) export const isAdmin = rule()(async (parent, args, ctx) => { return adminIsSignin(ctx) }) export const isResident = rule()(async (parent, args, ctx) => { try { const role = await getRole(ctx) return role === Role.Resident } catch { return false } }) export const isManager = rule()(async (parent, args, ctx) => { try { const role = await getRole(ctx) return role === Role.Manager } catch { return false } }) export const isProvider = rule()(async (parent, args, ctx) => { try { const role = await getRole(ctx) return role === Role.Provider } catch { return false } })