From 7843da246c828f62a602abc5405d3dc06e3ecb89 Mon Sep 17 00:00:00 2001 From: Alex Yang <32620988+DatProJack@users.noreply.github.com> Date: Wed, 7 Aug 2024 15:58:18 -0400 Subject: [PATCH] no eventId in put or post --- src/services/events/events-router.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/services/events/events-router.ts b/src/services/events/events-router.ts index 0cb8449..b01374b 100644 --- a/src/services/events/events-router.ts +++ b/src/services/events/events-router.ts @@ -102,6 +102,11 @@ eventsRouter.post( RoleChecker([Role.Enum.STAFF]), async (req, res, next) => { try { + if (req.body.eventId) { + return res.status(StatusCodes.BAD_REQUEST).json({ + error: "Invalid Parameters", + }); + } const validatedData = privateEventValidator.parse(req.body); const event = new Database.EVENTS(validatedData); await event.save(); @@ -118,7 +123,13 @@ eventsRouter.put( async (req, res, next) => { const eventId = req.params.EVENTID; try { + if (req.body.eventId) { + return res.status(StatusCodes.BAD_REQUEST).json({ + error: "Invalid Parameters", + }); + } const validatedData = privateEventValidator.parse(req.body); + validatedData.eventId = eventId; const event = await Database.EVENTS.findOneAndUpdate( { eventId: eventId }, { $set: validatedData }