Merge pull request #80 from calcom/fix/event-valid
fix: dont overdo validation on read event-type
This commit is contained in:
@@ -23,7 +23,10 @@ export const dateNotInPast = function (date: Date) {
|
||||
export const verifyApiKey: NextMiddleware = async (req, res, next) => {
|
||||
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_"
|
||||
const strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX || "cal_", "");
|
||||
let strippedApiKey = `${req.query.apiKey}`.replace(process.env.API_KEY_PREFIX, "");
|
||||
strippedApiKey = strippedApiKey.includes("cal_")
|
||||
? strippedApiKey.replace("cal_", "")
|
||||
: strippedApiKey;
|
||||
// Hash the key again before matching against the database records.
|
||||
const hashedKey = hashAPIKey(strippedApiKey);
|
||||
// Check if the hashed api key exists in database.
|
||||
|
||||
+7
-3
@@ -124,13 +124,17 @@ export type EventTypeCustomInputResponse = BaseResponse & {
|
||||
export type EventTypeCustomInputsResponse = BaseResponse & {
|
||||
event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
|
||||
};
|
||||
|
||||
export interface EventTypeMeta extends Omit<EventType, "locations" | "metadata" | "recurringEvent"> {
|
||||
locations?: JSON;
|
||||
metadata?: JSON;
|
||||
recurringEvent: JSON;
|
||||
}
|
||||
// EventType
|
||||
export type EventTypeResponse = BaseResponse & {
|
||||
event_type?: Partial<EventType>;
|
||||
event_type?: Partial<EventTypeMeta>;
|
||||
};
|
||||
export type EventTypesResponse = BaseResponse & {
|
||||
event_types?: Partial<EventType>[];
|
||||
event_types?: Partial<EventTypeMeta>[];
|
||||
};
|
||||
|
||||
// Payment
|
||||
|
||||
@@ -39,7 +39,7 @@ const schemaEventTypeCreateParams = z
|
||||
description: z.string().optional().nullable(),
|
||||
length: z.number().int(),
|
||||
locations: jsonSchema.optional().nullable().or(z.null()),
|
||||
metadata: z.any().optional().nullable().nullish(),
|
||||
metadata: z.any().optional().nullable().or(z.null()),
|
||||
recurringEvent: jsonSchema.optional().nullable().or(z.null()),
|
||||
})
|
||||
.strict();
|
||||
@@ -61,7 +61,6 @@ export const schemaEventTypeReadPublic = EventType.pick({
|
||||
title: true,
|
||||
slug: true,
|
||||
length: true,
|
||||
locations: true,
|
||||
hidden: true,
|
||||
position: true,
|
||||
userId: true,
|
||||
@@ -86,11 +85,6 @@ export const schemaEventTypeReadPublic = EventType.pick({
|
||||
slotInterval: true,
|
||||
successRedirectUrl: true,
|
||||
description: true,
|
||||
})
|
||||
.merge(
|
||||
z.object({
|
||||
recurringEvent: jsonSchema.nullable(),
|
||||
metadata: jsonSchema.nullable(),
|
||||
})
|
||||
)
|
||||
.strict();
|
||||
locations: true,
|
||||
metadata: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user