Merge pull request #81 from calcom/fix/dont-cal

Fix/dont cal
pull/9078/head
Agusti Fernandez Pardo 2022-05-18 21:51:13 +02:00 committed by GitHub
commit ba4abacb1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View File

@ -23,10 +23,7 @@ export const dateNotInPast = function (date: Date) {
export const verifyApiKey: NextMiddleware = async (req, res, next) => { export const verifyApiKey: NextMiddleware = async (req, res, next) => {
if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" }); if (!req.query.apiKey) return res.status(401).json({ message: "No apiKey provided" });
// We remove the prefix from the user provided api_key. If no env set default to "cal_" // We remove the prefix from the user provided api_key. If no env set default to "cal_"
let strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX, ""); const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "cal_", "");
strippedApiKey = strippedApiKey.includes("cal_")
? strippedApiKey.replace("cal_", "")
: strippedApiKey;
// Hash the key again before matching against the database records. // Hash the key again before matching against the database records.
const hashedKey = hashAPIKey(strippedApiKey); const hashedKey = hashAPIKey(strippedApiKey);
// Check if the hashed api key exists in database. // Check if the hashed api key exists in database.

View File

@ -125,9 +125,9 @@ export type EventTypeCustomInputsResponse = BaseResponse & {
event_type_custom_inputs?: Partial<EventTypeCustomInput>[]; event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
}; };
export interface EventTypeMeta extends Omit<EventType, "locations" | "metadata" | "recurringEvent"> { export interface EventTypeMeta extends Omit<EventType, "locations" | "metadata" | "recurringEvent"> {
locations?: JSON; locations: object | null;
metadata?: JSON; metadata: object | null;
recurringEvent: JSON; recurringEvent: object | null;
} }
// EventType // EventType
export type EventTypeResponse = BaseResponse & { export type EventTypeResponse = BaseResponse & {