diff --git a/src/routes/admin/calendar.ts b/src/routes/admin/calendar.ts index 37fd30c..e6f7181 100644 --- a/src/routes/admin/calendar.ts +++ b/src/routes/admin/calendar.ts @@ -11,47 +11,88 @@ import { deleteCalendarItem, deleteCalendarType, } from "../../controller/admin/calendarController"; +import PermissionHelper from "../../helpers/permissionHelper"; var router = express.Router({ mergeParams: true }); -router.get("/items", async (req: Request, res: Response) => { - await getAllCalendarItems(req, res); -}); +router.get( + "/items", + PermissionHelper.passCheckMiddleware("read", "club", "calendar"), + async (req: Request, res: Response) => { + await getAllCalendarItems(req, res); + } +); -router.get("/item/:id", async (req: Request, res: Response) => { - await getCalendarItemById(req, res); -}); +router.get( + "/item/:id", + PermissionHelper.passCheckMiddleware("read", "club", "calendar"), + async (req: Request, res: Response) => { + await getCalendarItemById(req, res); + } +); -router.get("/types", async (req: Request, res: Response) => { - await getAllCalendarTypes(req, res); -}); +router.get( + "/types", + PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await getAllCalendarTypes(req, res); + } +); -router.get("/type/:id", async (req: Request, res: Response) => { - await getCalendarTypeById(req, res); -}); +router.get( + "/type/:id", + PermissionHelper.passCheckMiddleware("read", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await getCalendarTypeById(req, res); + } +); -router.post("/item", async (req: Request, res: Response) => { - await createCalendarItem(req, res); -}); +router.post( + "/item", + PermissionHelper.passCheckMiddleware("create", "club", "calendar"), + async (req: Request, res: Response) => { + await createCalendarItem(req, res); + } +); -router.post("/type", async (req: Request, res: Response) => { - await createCalendarType(req, res); -}); +router.post( + "/type", + PermissionHelper.passCheckMiddleware("create", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await createCalendarType(req, res); + } +); -router.patch("/item/:id", async (req: Request, res: Response) => { - await updateCalendarItem(req, res); -}); +router.patch( + "/item/:id", + PermissionHelper.passCheckMiddleware("update", "club", "calendar"), + async (req: Request, res: Response) => { + await updateCalendarItem(req, res); + } +); -router.patch("/type/:id", async (req: Request, res: Response) => { - await updateCalendarType(req, res); -}); +router.patch( + "/type/:id", + PermissionHelper.passCheckMiddleware("update", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await updateCalendarType(req, res); + } +); -router.delete("/item/:id", async (req: Request, res: Response) => { - await deleteCalendarItem(req, res); -}); +router.delete( + "/item/:id", + PermissionHelper.passCheckMiddleware("delete", "club", "calendar"), + async (req: Request, res: Response) => { + await deleteCalendarItem(req, res); + } +); -router.delete("/type/:id", async (req: Request, res: Response) => { - await deleteCalendarType(req, res); -}); +router.delete( + "/type/:id", + PermissionHelper.passCheckMiddleware("delete", "settings", "calendar_type"), + async (req: Request, res: Response) => { + await deleteCalendarType(req, res); + } +); export default router; diff --git a/src/type/permissionTypes.ts b/src/type/permissionTypes.ts index 3bd54c8..f7f05a1 100644 --- a/src/type/permissionTypes.ts +++ b/src/type/permissionTypes.ts @@ -10,6 +10,7 @@ export type PermissionModule = | "executive_position" | "communication" | "membership_status" + | "calendar_type" | "user" | "role"; @@ -45,12 +46,13 @@ export const permissionModules: Array = [ "executive_position", "communication", "membership_status", + "calendar_type", "user", "role", ]; export const permissionTypes: Array = ["read", "create", "update", "delete"]; export const sectionsAndModules: SectionsAndModulesObject = { club: ["member", "calendar", "newsletter", "protocoll"], - settings: ["qualification", "award", "executive_position", "communication", "membership_status"], + settings: ["qualification", "award", "executive_position", "communication", "membership_status", "calendar_type"], user: ["user", "role"], };