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();