diff --git a/controllers/courses.js b/controllers/courses.js index 4f55c1db5b..b5ad205b47 100644 --- a/controllers/courses.js +++ b/controllers/courses.js @@ -774,9 +774,14 @@ 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.some((id) => id === currentUserId) - && !req.body.substitutionIds.some((id) => id === currentUserId); + const isRemovingYourself = !isAdministrator + && req.body.teacherIds + && req.body.substitutionIds + && !req.body.teacherIds.some((id) => id === currentUserId) + && !req.body.substitutionIds.some((id) => id === currentUserId); + if (isRemovingYourself) { // if you are removing yourself from a course you will not have permissions to create events anymore // so temporarily add yourself to the list of teachers diff --git a/views/courses/edit-course.hbs b/views/courses/edit-course.hbs index cc9cd73139..c72c73f4df 100644 --- a/views/courses/edit-course.hbs +++ b/views/courses/edit-course.hbs @@ -39,6 +39,7 @@