1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 18:39:32 +00:00

Should not allow teachers to remove the last teacher from class

This commit is contained in:
2022-03-31 13:49:03 +00:00
parent 6a36fae78c
commit 0b09a9a61e
2 changed files with 17 additions and 2 deletions

View File

@@ -240,8 +240,18 @@ router.post('/:id/:userType(members|teachers)/:userId/remove',
const u = await new User(req.db, null, req.params.userId);
const userType = req.params.userType;
await c.removeUser(u);
return res.redirect(`/admin/class/${c.id}/${userType}`);
try {
await c.removeUser(u);
return res.redirect(`/admin/class/${c.id}/${userType}`);
} catch (e) {
console.error(e);
return res.render('error', {
title: 'Stratos - Error',
current: 'Classes',
name: req.session.fullName,
msg: `Can not remove this user: ${e.message}`
});
}
}
);