From 68cf5bf573c408337de88bedea4ad834fc516367 Mon Sep 17 00:00:00 2001 From: Stephan <57194608+stephan418@users.noreply.github.com> Date: Thu, 9 Jun 2022 11:55:44 +0200 Subject: [PATCH] Address some comments and fix issues --- src/Controllers/participant.controller.ts | 4 +--- src/Routes/participant.routes.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Controllers/participant.controller.ts b/src/Controllers/participant.controller.ts index 94021ff..2b7e75e 100644 --- a/src/Controllers/participant.controller.ts +++ b/src/Controllers/participant.controller.ts @@ -20,8 +20,6 @@ const InitialParticipant = z.object({ groupPid: z.string().min(1).uuid(), }); -const ParticipantBody = InitialParticipant.extend({ teamPid: z.string().uuid() }); - const basicParticipant = { pid: true, firstName: true, @@ -133,7 +131,7 @@ export const getParticipantForRole = async (req: Request<{ rolePid: string }>, r export const createParticipant = async (req: Request<{ teamPid: string }>, res: Response) => { const { teamPid } = req.params; - const result = ParticipantBody.safeParse(req.body); + const result = InitialParticipant.safeParse(req.body); if (result.success === false) { return res.status(400).json( diff --git a/src/Routes/participant.routes.ts b/src/Routes/participant.routes.ts index 3fc9a8f..391e3e6 100644 --- a/src/Routes/participant.routes.ts +++ b/src/Routes/participant.routes.ts @@ -22,7 +22,7 @@ router.get( ); teamRouter.get( - "/:pid/particpants", + "/:teamPid/particpants", requireConfiguredAuthentication({ type: { admin: true, teamleader: true }, optional: false }), getAllParticipantsParams ); @@ -35,7 +35,7 @@ roleRouter.get( teamRouter.post<"/:teamPid/participants/", { teamPid: string }>( "/:teamPid/participants/", - requireConfiguredAuthentication({ optional: true, type: { admin: true, teamleader: true } }), + requireConfiguredAuthentication({ optional: false, type: { admin: true, teamleader: true } }), createParticipant );