Fixed permissions when adding teams
This commit is contained in:
@@ -60,10 +60,7 @@ export class TeamRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createTeam(req, res, next) {
|
createTeam(req, res, next) {
|
||||||
const role = req.user.role
|
if (!req.user.administrator) {
|
||||||
|
|
||||||
// If user's role is not Executive or Administrator, return an error
|
|
||||||
if (role !== 'executive' && role !== 'administrator') {
|
|
||||||
return next(new createError.Forbidden())
|
return next(new createError.Forbidden())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,11 +77,8 @@ export class TeamRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTeam(req, res, next) {
|
updateTeam(req, res, next) {
|
||||||
const role = req.user.role
|
if (!req.user.administrator) {
|
||||||
|
return next(new createError.Forbidden())
|
||||||
// If user's role is not Executive or Administrator, return an error
|
|
||||||
if (role !== 'executive' && role !== 'administrator') {
|
|
||||||
return new createError.Forbidden()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do this here because Mongoose will add it automatically otherwise
|
// Do this here because Mongoose will add it automatically otherwise
|
||||||
@@ -130,11 +124,8 @@ export class TeamRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteTeam(req, res, next) {
|
deleteTeam(req, res, next) {
|
||||||
const role = req.user.role
|
if (!req.user.administrator) {
|
||||||
|
return next(new createError.Forbidden())
|
||||||
// If user's role is not Executive or Administrator, return an error
|
|
||||||
if (role !== 'executive' && role !== 'administrator') {
|
|
||||||
return new createError.Forbidden()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Team = this.db.Team
|
const Team = this.db.Team
|
||||||
|
|||||||
Reference in New Issue
Block a user