2017-05-22 13:58:25 -05:00
|
|
|
import { logger } from '../helpers'
|
2016-08-04 15:32:36 -05:00
|
|
|
|
|
|
|
function ensureIsAdmin (req, res, next) {
|
|
|
|
const user = res.locals.oauth.token.user
|
2017-04-26 14:42:36 -05:00
|
|
|
if (user.isAdmin() === false) {
|
2016-08-04 15:32:36 -05:00
|
|
|
logger.info('A non admin user is trying to access to an admin content.')
|
|
|
|
return res.sendStatus(403)
|
|
|
|
}
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2017-05-15 15:22:03 -05:00
|
|
|
export {
|
|
|
|
ensureIsAdmin
|
|
|
|
}
|