]>
Commit | Line | Data |
---|---|---|
e02643f3 | 1 | import { logger } from '../helpers' |
9bd26629 | 2 | |
9bd26629 C |
3 | function ensureIsAdmin (req, res, next) { |
4 | const user = res.locals.oauth.token.user | |
ab683a8e | 5 | if (user.isAdmin() === false) { |
9bd26629 C |
6 | logger.info('A non admin user is trying to access to an admin content.') |
7 | return res.sendStatus(403) | |
8 | } | |
9 | ||
10 | return next() | |
11 | } | |
12 | ||
13 | // --------------------------------------------------------------------------- | |
14 | ||
65fcc311 C |
15 | export { |
16 | ensureIsAdmin | |
17 | } |