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

10 lines
325 B
TypeScript
Raw Permalink Normal View History

2023-05-19 17:38:19 +00:00
import type { NextApiRequest } from "next";
2023-05-05 14:33:24 +00:00
import { UserPermissionRole } from "@calcom/prisma/enums";
export const isAdminGuard = async (req: NextApiRequest) => {
const { userId, prisma } = req;
2022-06-08 16:52:25 +00:00
const user = await prisma.user.findUnique({ where: { id: userId } });
return user?.role === UserPermissionRole.ADMIN;
};