From 45a0a5cc6e58c267c9d525b71d5a588d29fd0e71 Mon Sep 17 00:00:00 2001 From: Max Bischof Date: Thu, 28 Sep 2023 16:11:32 +0200 Subject: [PATCH] Add isAdministrator condition --- controllers/courses.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/courses.js b/controllers/courses.js index 62719e1be7..b5ad205b47 100644 --- a/controllers/courses.js +++ b/controllers/courses.js @@ -774,8 +774,10 @@ router.patch('/:courseId', async (req, res, next) => { } const { courseId } = req.params; + const isAdministrator = res.locals.currentRole === 'Administrator'; const currentUserId = res.locals.currentUser._id; - const isRemovingYourself = req.body.teacherIds + const isRemovingYourself = !isAdministrator + && req.body.teacherIds && req.body.substitutionIds && !req.body.teacherIds.some((id) => id === currentUserId) && !req.body.substitutionIds.some((id) => id === currentUserId);