route permissions

This commit is contained in:
Julian Krauser 2024-09-17 13:44:54 +02:00
parent cc763001a5
commit 80b1b5cf62
6 changed files with 237 additions and 99 deletions

View file

@ -6,6 +6,7 @@ import {
getAwardById,
updateAward,
} from "../../controller/admin/awardController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true });
@ -17,16 +18,28 @@ router.get("/:id", async (req: Request, res: Response) => {
await getAwardById(req, res);
});
router.post("/", async (req: Request, res: Response) => {
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "settings", "award"),
async (req: Request, res: Response) => {
await createAward(req, res);
});
}
);
router.patch("/:id", async (req: Request, res: Response) => {
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "settings", "award"),
async (req: Request, res: Response) => {
await updateAward(req, res);
});
}
);
router.delete("/:id", async (req: Request, res: Response) => {
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "settings", "award"),
async (req: Request, res: Response) => {
await deleteAward(req, res);
});
}
);
export default router;

View file

@ -7,6 +7,7 @@ import {
getCommunicationTypeById,
updateCommunicationType,
} from "../../controller/admin/communicationTypeController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true });
@ -22,16 +23,28 @@ router.get("/:id", async (req: Request, res: Response) => {
await getCommunicationTypeById(req, res);
});
router.post("/", async (req: Request, res: Response) => {
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "settings", "communication"),
async (req: Request, res: Response) => {
await createCommunicationType(req, res);
});
}
);
router.patch("/:id", async (req: Request, res: Response) => {
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "settings", "communication"),
async (req: Request, res: Response) => {
await updateCommunicationType(req, res);
});
}
);
router.delete("/:id", async (req: Request, res: Response) => {
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "settings", "communication"),
async (req: Request, res: Response) => {
await deleteCommunicationType(req, res);
});
}
);
export default router;

View file

@ -6,6 +6,7 @@ import {
getExecutivePositionById,
updateExecutivePosition,
} from "../../controller/admin/executivePositionController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true });
@ -17,16 +18,28 @@ router.get("/:id", async (req: Request, res: Response) => {
await getExecutivePositionById(req, res);
});
router.post("/", async (req: Request, res: Response) => {
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "settings", "executive_position"),
async (req: Request, res: Response) => {
await createExecutivePosition(req, res);
});
}
);
router.patch("/:id", async (req: Request, res: Response) => {
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "settings", "executive_position"),
async (req: Request, res: Response) => {
await updateExecutivePosition(req, res);
});
}
);
router.delete("/:id", async (req: Request, res: Response) => {
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "settings", "executive_position"),
async (req: Request, res: Response) => {
await deleteExecutivePosition(req, res);
});
}
);
export default router;

View file

@ -26,6 +26,7 @@ import {
updateMembershipOfMember,
updateQualificationOfMember,
} from "../../controller/admin/memberController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true });
@ -57,76 +58,148 @@ router.get("/:memberId/communications", async (req: Request, res: Response) => {
await getCommunicationsByMember(req, res);
});
router.post("/", async (req: Request, res: Response) => {
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "club", "member"),
async (req: Request, res: Response) => {
await createMember(req, res);
});
}
);
router.post("/:memberId/membership", async (req: Request, res: Response) => {
router.post(
"/:memberId/membership",
PermissionHelper.passCheckMiddleware("create", "club", "member"),
async (req: Request, res: Response) => {
await addMembershipToMember(req, res);
});
}
);
router.post("/:memberId/award", async (req: Request, res: Response) => {
router.post(
"/:memberId/award",
PermissionHelper.passCheckMiddleware("create", "club", "member"),
async (req: Request, res: Response) => {
await addAwardToMember(req, res);
});
}
);
router.post("/:memberId/qualification", async (req: Request, res: Response) => {
router.post(
"/:memberId/qualification",
PermissionHelper.passCheckMiddleware("create", "club", "member"),
async (req: Request, res: Response) => {
await addQualificationToMember(req, res);
});
}
);
router.post("/:memberId/position", async (req: Request, res: Response) => {
router.post(
"/:memberId/position",
PermissionHelper.passCheckMiddleware("create", "club", "member"),
async (req: Request, res: Response) => {
await addExecutivePositionToMember(req, res);
});
}
);
router.post("/:memberId/communication", async (req: Request, res: Response) => {
router.post(
"/:memberId/communication",
PermissionHelper.passCheckMiddleware("create", "club", "member"),
async (req: Request, res: Response) => {
await addCommunicationToMember(req, res);
});
}
);
router.patch("/:id", async (req: Request, res: Response) => {
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "club", "member"),
async (req: Request, res: Response) => {
await updateMemberById(req, res);
});
}
);
router.patch("/:memberId/membership/:recordId", async (req: Request, res: Response) => {
router.patch(
"/:memberId/membership/:recordId",
PermissionHelper.passCheckMiddleware("update", "club", "member"),
async (req: Request, res: Response) => {
await updateMembershipOfMember(req, res);
});
}
);
router.patch("/:memberId/award/:recordId", async (req: Request, res: Response) => {
router.patch(
"/:memberId/award/:recordId",
PermissionHelper.passCheckMiddleware("update", "club", "member"),
async (req: Request, res: Response) => {
await updateAwardOfMember(req, res);
});
}
);
router.patch("/:memberId/qualification/:recordId", async (req: Request, res: Response) => {
router.patch(
"/:memberId/qualification/:recordId",
PermissionHelper.passCheckMiddleware("update", "club", "member"),
async (req: Request, res: Response) => {
await updateQualificationOfMember(req, res);
});
}
);
router.patch("/:memberId/position/:recordId", async (req: Request, res: Response) => {
router.patch(
"/:memberId/position/:recordId",
PermissionHelper.passCheckMiddleware("update", "club", "member"),
async (req: Request, res: Response) => {
await updateExecutivePositionOfMember(req, res);
});
}
);
router.patch("/:memberId/communication/:recordId", async (req: Request, res: Response) => {
router.patch(
"/:memberId/communication/:recordId",
PermissionHelper.passCheckMiddleware("update", "club", "member"),
async (req: Request, res: Response) => {
await updateCommunicationOfMember(req, res);
});
}
);
router.delete("/:id", async (req: Request, res: Response) => {
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "club", "member"),
async (req: Request, res: Response) => {
await deleteMemberById(req, res);
});
}
);
router.delete("/:memberId/membership/:recordId", async (req: Request, res: Response) => {
router.delete(
"/:memberId/membership/:recordId",
PermissionHelper.passCheckMiddleware("delete", "club", "member"),
async (req: Request, res: Response) => {
await deleteMembershipOfMember(req, res);
});
}
);
router.delete("/:memberId/award/:recordId", async (req: Request, res: Response) => {
router.delete(
"/:memberId/award/:recordId",
PermissionHelper.passCheckMiddleware("delete", "club", "member"),
async (req: Request, res: Response) => {
await deleteAwardOfMember(req, res);
});
}
);
router.delete("/:memberId/qualification/:recordId", async (req: Request, res: Response) => {
router.delete(
"/:memberId/qualification/:recordId",
PermissionHelper.passCheckMiddleware("delete", "club", "member"),
async (req: Request, res: Response) => {
await deleteQualificationOfMember(req, res);
});
}
);
router.delete("/:memberId/position/:recordId", async (req: Request, res: Response) => {
router.delete(
"/:memberId/position/:recordId",
PermissionHelper.passCheckMiddleware("delete", "club", "member"),
async (req: Request, res: Response) => {
await deleteExecutivePositionOfMember(req, res);
});
}
);
router.delete("/:memberId/communication/:recordId", async (req: Request, res: Response) => {
router.delete(
"/:memberId/communication/:recordId",
PermissionHelper.passCheckMiddleware("delete", "club", "member"),
async (req: Request, res: Response) => {
await deleteCommunicationOfMember(req, res);
});
}
);
export default router;

View file

@ -6,6 +6,7 @@ import {
getMembershipStatusById,
updateMembershipStatus,
} from "../../controller/admin/membershipStatusController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true });
@ -17,16 +18,28 @@ router.get("/:id", async (req: Request, res: Response) => {
await getMembershipStatusById(req, res);
});
router.post("/", async (req: Request, res: Response) => {
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "settings", "membership_status"),
async (req: Request, res: Response) => {
await createMembershipStatus(req, res);
});
}
);
router.patch("/:id", async (req: Request, res: Response) => {
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "settings", "membership_status"),
async (req: Request, res: Response) => {
await updateMembershipStatus(req, res);
});
}
);
router.delete("/:id", async (req: Request, res: Response) => {
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "settings", "membership_status"),
async (req: Request, res: Response) => {
await deleteMembershipStatus(req, res);
});
}
);
export default router;

View file

@ -6,6 +6,7 @@ import {
getQualificationById,
updateQualification,
} from "../../controller/admin/qualificationController";
import PermissionHelper from "../../helpers/permissionHelper";
var router = express.Router({ mergeParams: true });
@ -17,16 +18,28 @@ router.get("/:id", async (req: Request, res: Response) => {
await getQualificationById(req, res);
});
router.post("/", async (req: Request, res: Response) => {
router.post(
"/",
PermissionHelper.passCheckMiddleware("create", "settings", "qualification"),
async (req: Request, res: Response) => {
await createQualification(req, res);
});
}
);
router.patch("/:id", async (req: Request, res: Response) => {
router.patch(
"/:id",
PermissionHelper.passCheckMiddleware("update", "settings", "qualification"),
async (req: Request, res: Response) => {
await updateQualification(req, res);
});
}
);
router.delete("/:id", async (req: Request, res: Response) => {
router.delete(
"/:id",
PermissionHelper.passCheckMiddleware("delete", "settings", "qualification"),
async (req: Request, res: Response) => {
await deleteQualification(req, res);
});
}
);
export default router;