feat: adds license check
This commit is contained in:
1 parent
915610763e
commit
12fe6af995
2 files changed
+8
-1
No files matched your search
+4
-1
@@ -1,3 +1,6 @@
|
||||
API_KEY_PREFIX=cal_
|
||||
DATABASE_URL="postgresql://postgres:@localhost:5450/calendso"
|
||||
NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_WEBAPP_URL=http://localhost:3000
|
||||
|
||||
# Get it in console.cal.com
|
||||
CALCOM_LICENSE_KEY=""
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextMiddleware } from "next-api-middleware";
|
||||
|
||||
import { hashAPIKey } from "@calcom/features/ee/api-keys/lib/apiKeys";
|
||||
import checkLicense from "@calcom/features/ee/common/server/checkLicense";
|
||||
|
||||
import { isAdminGuard } from "@lib/utils/isAdmin";
|
||||
|
||||
@@ -14,6 +15,9 @@ 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 || "");
|
||||
if (!hasValidLicense)
|
||||
return res.status(401).json({ error: "Invalid or missing CALCOM_LICENSE_KEY environment variable" });
|
||||
const { prisma, userId, isAdmin } = req;
|
||||
// If the user is an admin and using a license key (from customPrisma), skip the apiKey check.
|
||||
if (userId === 0 && isAdmin) {
|
||||
|
||||
Reference in new issue
Block a user