Scheduling infrastructure for absolutely everyone.
fix: userId not 0 for fixing /me endpoint
Agusti Fernandez Pardobe200cd07676
diff --git a/lib/helpers/customPrisma.ts b/lib/helpers/customPrisma.tsindex f2d038c5e5b..f3740484998 100644--- a/lib/helpers/customPrisma.ts+++ b/lib/helpers/customPrisma.ts@@ -47,7 +47,7 @@ export const customPrismaClient: NextMiddleware = async (req, res, next) => {we skip verifyApiKey logic and pass onto next middleware instead.*/req.isAdmin = true;- req.userId = 0;+ req.isCustomPrisma = true;await next();};diff --git a/lib/helpers/extendRequest.ts b/lib/helpers/extendRequest.tsindex 2924782d3e7..d01cce81e2b 100644--- a/lib/helpers/extendRequest.ts+++ b/lib/helpers/extendRequest.ts@@ -15,6 +15,7 @@ declare module "next" {session: { user: { id: number } };query: Partial<{ [key: string]: string | string[] }>;isAdmin: boolean;+ isCustomPrisma: boolean;pagination: { take: number; skip: number };}}diff --git a/lib/helpers/verifyApiKey.ts b/lib/helpers/verifyApiKey.tsindex 408cc553561..ee252d91fde 100644--- a/lib/helpers/verifyApiKey.ts+++ b/lib/helpers/verifyApiKey.ts@@ -18,9 +18,9 @@ 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;+ const { prisma, isCustomPrisma, isAdmin } = req;// If the user is an admin and using a license key (from customPrisma), skip the apiKey check.- if (userId === 0 && isAdmin) {+ if (isCustomPrisma && isAdmin) {await next();return;}@@ -42,6 +42,6 @@ export const verifyApiKey: NextMiddleware = async (req, res, next) => {req.userId = apiKey.userId;// save the isAdmin boolean here for later usereq.isAdmin = await isAdminGuard(req);-+ req.isCustomPrisma = false;await next();};