aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/middlewares/admin.ts
blob: ebafa36a4f90d04f7bb0278ec7b9654001cfca8b (plain) (tree)
1
2
3
4
5

                                           

                                          
                                 








                                                                              


               
const logger = require('../helpers/logger')

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
}