cal.pub0.org/lib/utils/isAdmin.ts

7 lines
271 B
TypeScript

import { PrismaClient, UserPermissionRole } from "@prisma/client";
export const isAdminGuard = async (userId: number, prisma: PrismaClient) => {
const user = await prisma.user.findUnique({ where: { id: userId } });
return user?.role === UserPermissionRole.ADMIN;
};