From 94d2cfcb3b47e0205eba7a0a8689a37babc98637 Mon Sep 17 00:00:00 2001 From: Bijay Jiwrajka Date: Tue, 16 Jan 2024 18:32:30 +0530 Subject: [PATCH 1/4] fix minor bug --- src/controllers/event/add.ts | 1 + src/controllers/event/update.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/event/add.ts b/src/controllers/event/add.ts index 971b87b..8bb6d29 100644 --- a/src/controllers/event/add.ts +++ b/src/controllers/event/add.ts @@ -51,6 +51,7 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => { if (extraQuestions && !Array.isArray(extraQuestions)) { return next(Errors.Module.invalidInput); } + if (minTeamSize > maxTeamSize) return next(Errors.Module.invalidInput); if ( !(registrationIncentive && typeof registrationIncentive === "number") || diff --git a/src/controllers/event/update.ts b/src/controllers/event/update.ts index 28051e4..6f90c9b 100644 --- a/src/controllers/event/update.ts +++ b/src/controllers/event/update.ts @@ -27,7 +27,7 @@ const updateEvent: Interfaces.Controller.Async = async (req, res, next) => { const { eventId: EID } = req.params; const eventId = String(EID); if ( - String(eventId + "") || + // String(eventId + "") || typeof eventId !== "string" || eventId.length !== 24 ) From eb14b5bcb7a7be919685738755e66b09747cb8db Mon Sep 17 00:00:00 2001 From: Bijay Jiwrajka Date: Tue, 16 Jan 2024 19:12:40 +0530 Subject: [PATCH 2/4] Add checks for event reg --- src/controllers/event/add.ts | 4 ++++ src/controllers/event/update.ts | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/controllers/event/add.ts b/src/controllers/event/add.ts index 8bb6d29..55e98e5 100644 --- a/src/controllers/event/add.ts +++ b/src/controllers/event/add.ts @@ -76,9 +76,13 @@ const createEvent: Interfaces.Controller.Async = async (req, res, next) => { const regStart = new Date(registrationStartTime); const regEnd = new Date(registrationEndTime); + if (JSON.stringify(regStart) === "null" || JSON.stringify(regEnd) === "null") return next(Errors.Module.invalidInput); + if (regStart && regEnd && regStart > regEnd) + return next(Errors.Module.invalidInput); + if ( !(await prisma.module.findFirst({ where: { id: moduleId }, diff --git a/src/controllers/event/update.ts b/src/controllers/event/update.ts index 6f90c9b..661c8da 100644 --- a/src/controllers/event/update.ts +++ b/src/controllers/event/update.ts @@ -33,23 +33,33 @@ const updateEvent: Interfaces.Controller.Async = async (req, res, next) => { ) return next(Errors.Module.invalidInput); - if (!(await prisma.event.findFirst({ where: { id: eventId } }))) - return next(Errors.Module.eventNotFound); + const eventOriginal = await prisma.event.findFirst({ + where: { id: eventId }, + }); + if (!eventOriginal) return next(Errors.Module.eventNotFound); if (moduleId) { if (!moduleId || typeof moduleId !== "string" || eventId.length !== 24) return next(Errors.Module.invalidInput); if (!(await prisma.module.findFirst({ where: { id: moduleId } }))) return next(Errors.Module.moduleNotFound); } - + if (minTeamSize > maxTeamSize) return next(Errors.Module.invalidInput); let regStart; if (registrationStartTime) regStart = new Date(registrationStartTime); + else { + regStart = new Date(eventOriginal.registrationStartTime); + } let regEnd; if (registrationEndTime) regEnd = new Date(registrationEndTime); + else { + regEnd = new Date(eventOriginal.registrationEndTime); + } if (registrationStartTime && JSON.stringify(regStart) === "null") return next(Errors.Module.invalidInput); if (registrationEndTime && JSON.stringify(regEnd) === "null") return next(Errors.Module.invalidInput); + if (regStart && regEnd && regStart > regEnd) + return next(Errors.Module.invalidInput); const { organizers, managers }: { organizers: [string]; managers: [string] } = req.body; From a715006de085210d2539a00e4d3cffc936837cd0 Mon Sep 17 00:00:00 2001 From: Bijay Jiwrajka Date: Wed, 17 Jan 2024 17:08:35 +0530 Subject: [PATCH 3/4] get team id and name --- src/controllers/team/details.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/team/details.ts b/src/controllers/team/details.ts index 3275bae..6ddf6c3 100644 --- a/src/controllers/team/details.ts +++ b/src/controllers/team/details.ts @@ -86,6 +86,8 @@ const getAllTeamsOfEvent: Interfaces.Controller.Async = async ( ], }, select: { + teamName: true, + id: true, members: { select: { user: { From 68c92f57976870e49712c5aafa49fc188c2596b5 Mon Sep 17 00:00:00 2001 From: Bijay Jiwrajka Date: Wed, 17 Jan 2024 18:39:02 +0530 Subject: [PATCH 4/4] remove comment --- src/controllers/event/update.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/controllers/event/update.ts b/src/controllers/event/update.ts index 661c8da..2e32539 100644 --- a/src/controllers/event/update.ts +++ b/src/controllers/event/update.ts @@ -26,11 +26,7 @@ const updateEvent: Interfaces.Controller.Async = async (req, res, next) => { const { eventId: EID } = req.params; const eventId = String(EID); - if ( - // String(eventId + "") || - typeof eventId !== "string" || - eventId.length !== 24 - ) + if (typeof eventId !== "string" || eventId.length !== 24) return next(Errors.Module.invalidInput); const eventOriginal = await prisma.event.findFirst({