aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/admin.ts
blob: 28b6a9a120a24b8a23fb953fe463504cae897125 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { logger } from '../helpers'

function ensureIsAdmin (req, res, next) {
  const user = res.locals.oauth.token.user
  if (user.isAdmin() === false) {
    logger.info('A non admin user is trying to access to an admin content.')
    return res.sendStatus(403)
  }

  return next()
}

// ---------------------------------------------------------------------------

export {
  ensureIsAdmin
}