From 0b2724124acdf91f76ef1d7c3b55ac5868e6dd44 Mon Sep 17 00:00:00 2001 From: zomars Date: Wed, 8 Feb 2023 10:55:46 -0700 Subject: [PATCH] Updated checkLicense --- lib/helpers/verifyApiKey.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.ts index 3f8731c33c..2420dc4358 100644 --- a/lib/helpers/verifyApiKey.ts +++ b/lib/helpers/verifyApiKey.ts @@ -15,10 +15,10 @@ export const dateNotInPast = function (date: Date) { // This verifies the apiKey and sets the user if it is valid. export const verifyApiKey: NextMiddleware = async (req, res, next) => { - const hasValidLicense = await checkLicense(process.env.CALCOM_LICENSE_KEY || ""); + const { prisma, isCustomPrisma, isAdmin } = req; + const hasValidLicense = await checkLicense(prisma); if (!hasValidLicense) return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" }); - const { prisma, isCustomPrisma, isAdmin } = req; // If the user is an admin and using a license key (from customPrisma), skip the apiKey check. if (isCustomPrisma && isAdmin) { await next();