Skip to content

Commit

Permalink
Add isAdministrator condition
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax committed Sep 28, 2023
1 parent 0d5d732 commit 45a0a5c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion controllers/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 45a0a5c

Please sign in to comment.