]>
Commit | Line | Data |
---|---|---|
1 | import { logger } from '../helpers' | |
2 | ||
3 | function ensureIsAdmin (req, res, next) { | |
4 | const user = res.locals.oauth.token.user | |
5 | if (user.isAdmin() === false) { | |
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 | ||
15 | export { | |
16 | ensureIsAdmin | |
17 | } |