From a112805fbba04ce37227a7aa756e1390daf7aee1 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Mon, 21 Oct 2024 10:25:13 +0200 Subject: [PATCH] permissions --- src/routes/admin/protocol.ts | 101 ++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/src/routes/admin/protocol.ts b/src/routes/admin/protocol.ts index 7cc29a4..48c5e6c 100644 --- a/src/routes/admin/protocol.ts +++ b/src/routes/admin/protocol.ts @@ -19,6 +19,7 @@ import { synchronizeProtocolPrecenseById, synchronizeProtocolVotingsById, } from "../../controller/admin/protocolController"; +import PermissionHelper from "../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); @@ -54,44 +55,84 @@ router.get("/:protocolId/printout/:printoutId", async (req: Request, res: Respon await getProtocolPrintoutByIdAndPrint(req, res); }); -router.post("/", async (req: Request, res: Response) => { - await createProtocol(req, res); -}); +router.post( + "/", + PermissionHelper.passCheckMiddleware("create", "club", "protocol"), + async (req: Request, res: Response) => { + await createProtocol(req, res); + } +); -router.post("/:protocolId/agenda", async (req: Request, res: Response) => { - await createProtocolAgendaById(req, res); -}); +router.post( + "/:protocolId/agenda", + PermissionHelper.passCheckMiddleware("create", "club", "protocol"), + async (req: Request, res: Response) => { + await createProtocolAgendaById(req, res); + } +); -router.post("/:protocolId/decision", async (req: Request, res: Response) => { - await createProtocolDecisonsById(req, res); -}); +router.post( + "/:protocolId/decision", + PermissionHelper.passCheckMiddleware("create", "club", "protocol"), + async (req: Request, res: Response) => { + await createProtocolDecisonsById(req, res); + } +); -router.post("/:protocolId/voting", async (req: Request, res: Response) => { - await createProtocolVotingsById(req, res); -}); +router.post( + "/:protocolId/voting", + PermissionHelper.passCheckMiddleware("create", "club", "protocol"), + async (req: Request, res: Response) => { + await createProtocolVotingsById(req, res); + } +); -router.post("/:protocolId/printout", async (req: Request, res: Response) => { - await createProtocolPrintoutById(req, res); -}); +router.post( + "/:protocolId/printout", + PermissionHelper.passCheckMiddleware("create", "club", "protocol"), + async (req: Request, res: Response) => { + await createProtocolPrintoutById(req, res); + } +); -router.patch("/:id/synchronize", async (req: Request, res: Response) => { - await synchronizeProtocolById(req, res); -}); +router.patch( + "/:id/synchronize", + PermissionHelper.passCheckMiddleware("update", "club", "protocol"), + async (req: Request, res: Response) => { + await synchronizeProtocolById(req, res); + } +); -router.patch("/:protocolId/synchronize/agenda", async (req: Request, res: Response) => { - await synchronizeProtocolAgendaById(req, res); -}); +router.patch( + "/:protocolId/synchronize/agenda", + PermissionHelper.passCheckMiddleware("update", "club", "protocol"), + async (req: Request, res: Response) => { + await synchronizeProtocolAgendaById(req, res); + } +); -router.patch("/:protocolId/synchronize/decisions", async (req: Request, res: Response) => { - await synchronizeProtocolDecisonsById(req, res); -}); +router.patch( + "/:protocolId/synchronize/decisions", + PermissionHelper.passCheckMiddleware("update", "club", "protocol"), + async (req: Request, res: Response) => { + await synchronizeProtocolDecisonsById(req, res); + } +); -router.patch("/:protocolId/synchronize/votings", async (req: Request, res: Response) => { - await synchronizeProtocolVotingsById(req, res); -}); +router.patch( + "/:protocolId/synchronize/votings", + PermissionHelper.passCheckMiddleware("update", "club", "protocol"), + async (req: Request, res: Response) => { + await synchronizeProtocolVotingsById(req, res); + } +); -router.put("/:protocolId/synchronize/presence", async (req: Request, res: Response) => { - await synchronizeProtocolPrecenseById(req, res); -}); +router.put( + "/:protocolId/synchronize/presence", + PermissionHelper.passCheckMiddleware("update", "club", "protocol"), + async (req: Request, res: Response) => { + await synchronizeProtocolPrecenseById(req, res); + } +); export default router;