diff --git a/server/src/client/middleware/Permissions.js b/server/src/client/middleware/Permissions.js index 1b0e441..5fa5a92 100644 --- a/server/src/client/middleware/Permissions.js +++ b/server/src/client/middleware/Permissions.js @@ -2,8 +2,9 @@ const Permissions = (perm) => { return (req, res, next) => { const { user: { permissions } } = req; - if (permissions[perm]) return next(); - res.status(401).end(); + if (permissions.admin || permissions[perm]) return next(); + req.client.logger.warn(`${req.user.tag} has insufficient permissions for ${perm}`); + return res.status(403).send('Insufficient permissions'); }; diff --git a/server/src/client/middleware/index.js b/server/src/client/middleware/index.js index a43e787..fcdd111 100644 --- a/server/src/client/middleware/index.js +++ b/server/src/client/middleware/index.js @@ -1,4 +1,4 @@ module.exports = { - CheckAuth: require('./Auth.js'), + ...require('./Auth.js'), Permissions: require('./Permissions.js'), }; \ No newline at end of file