diff options
Diffstat (limited to 'server/middlewares/admin.js')
-rw-r--r-- | server/middlewares/admin.js | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/server/middlewares/admin.js b/server/middlewares/admin.js index e6d9dc887..3288f4c6b 100644 --- a/server/middlewares/admin.js +++ b/server/middlewares/admin.js | |||
@@ -1,6 +1,5 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const constants = require('../initializers/constants') | ||
4 | const logger = require('../helpers/logger') | 3 | const logger = require('../helpers/logger') |
5 | 4 | ||
6 | const adminMiddleware = { | 5 | const adminMiddleware = { |
@@ -9,7 +8,7 @@ const adminMiddleware = { | |||
9 | 8 | ||
10 | function ensureIsAdmin (req, res, next) { | 9 | function ensureIsAdmin (req, res, next) { |
11 | const user = res.locals.oauth.token.user | 10 | const user = res.locals.oauth.token.user |
12 | if (user.role !== constants.USER_ROLES.ADMIN) { | 11 | if (user.isAdmin() === false) { |
13 | logger.info('A non admin user is trying to access to an admin content.') | 12 | logger.info('A non admin user is trying to access to an admin content.') |
14 | return res.sendStatus(403) | 13 | return res.sendStatus(403) |
15 | } | 14 | } |