From 0e21cc4c2001660105370fb765cca4e844d63801 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 26 Mar 2022 14:16:28 +0200 Subject: [PATCH] a --- server/src/client/middleware/Permissions.js | 5 +++-- server/src/client/middleware/index.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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