fix set headers error by adding missing return

pull/9078/head
Agusti Fernandez Pardo 2022-06-23 23:20:07 +02:00
parent c3996221e1
commit aa64f32378
1 changed files with 4 additions and 1 deletions

View File

@ -16,7 +16,10 @@ export const dateNotInPast = function (date: Date) {
export const verifyApiKey: NextMiddleware = async (req, res, next) => {
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) await next();
if (userId === 0 && isAdmin) {
await next();
return;
}
// Check if the apiKey query param is provided.
if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" });
// remove the prefix from the user provided api_key. If no env set default to "cal_"