fix: improve admin check using enum instead of string

pull/9078/head
Agusti Fernandez Pardo 2022-05-31 20:46:09 +02:00
parent 187d5f2b10
commit 7f42cc8479
1 changed files with 2 additions and 1 deletions

View File

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