From a36a5e7d204f2728fe9a4c7917064b1ce313fb5e Mon Sep 17 00:00:00 2001 From: Alex Yang <32620988+DatProJack@users.noreply.github.com> Date: Tue, 16 Jul 2024 23:23:37 -0400 Subject: [PATCH 1/2] GET /attendee/points --- src/services/attendee/attendee-router.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/services/attendee/attendee-router.ts b/src/services/attendee/attendee-router.ts index 42ad60d..88cf1a0 100644 --- a/src/services/attendee/attendee-router.ts +++ b/src/services/attendee/attendee-router.ts @@ -130,6 +130,30 @@ attendeeRouter.get( } ); +attendeeRouter.get( + "/points", + RoleChecker([Role.Enum.ADMIN]), + async (req, res, next) => { + try { + const payload = res.locals.payload; + const userId = payload.userId; + + // Check if the user exists in the database + const user = await Database.ATTENDEE.findOne({ userId }); + + if (!user) { + return res + .status(StatusCodes.NOT_FOUND) + .json({ error: "UserNotFound" }); + } + + return res.status(StatusCodes.OK).json({ points: user.points }); + } catch (error) { + next(error); + } + } +); + attendeeRouter.get( "/", RoleChecker([Role.Enum.USER]), From 4bfe90d47d85b3ee5c27f2f224efb3328f0c340d Mon Sep 17 00:00:00 2001 From: Alex Yang <32620988+aletya@users.noreply.github.com> Date: Tue, 16 Jul 2024 23:24:57 -0400 Subject: [PATCH 2/2] Update attendee-router.ts --- src/services/attendee/attendee-router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/attendee/attendee-router.ts b/src/services/attendee/attendee-router.ts index 88cf1a0..41d827e 100644 --- a/src/services/attendee/attendee-router.ts +++ b/src/services/attendee/attendee-router.ts @@ -132,7 +132,7 @@ attendeeRouter.get( attendeeRouter.get( "/points", - RoleChecker([Role.Enum.ADMIN]), + RoleChecker([Role.Enum.USER]), async (req, res, next) => { try { const payload = res.locals.payload;