feat: credentials, teams

This commit is contained in:
Agusti Fernandez Pardo committed 2022-04-13 02:12:16 +02:00
1 parent 9447bd859d
commit d987d52dbb
8 files changed
+85 -55

No files matched your search

+2 -2
View File
@@ -15,7 +15,7 @@ const today = new Date();
export const verifyApiKey: NextMiddleware = async (req, res, next) => {
if (!req.query.apiKey) res.status(401).json({ message: "No API key provided" });
const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "cal_", "");
const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "pt_secret_", "");
const hashedKey = hashAPIKey(strippedApiKey);
await prisma.apiKey
@@ -25,7 +25,7 @@ export const verifyApiKey: NextMiddleware = async (req, res, next) => {
res.status(401).json({ error: "You did not provide an api key" });
throw new Error("No api key found");
}
if (apiKey.userId) res.setHeader("X-Calcom-User-ID", apiKey?.userId);
if (apiKey.userId) res.setHeader("X-Calcom-User-ID", apiKey.userId);
if (apiKey.expiresAt && apiKey.userId && dateInPast(today, apiKey.expiresAt)) await next();
})
.catch((error) => {