PeerTube/server/middlewares/admin.ts

18 lines
403 B
TypeScript
Raw Normal View History

const logger = require('../helpers/logger')
function ensureIsAdmin (req, res, next) {
const user = res.locals.oauth.token.user
2017-04-26 21:42:36 +02:00
if (user.isAdmin() === false) {
logger.info('A non admin user is trying to access to an admin content.')
return res.sendStatus(403)
}
return next()
}
// ---------------------------------------------------------------------------
2017-05-15 22:22:03 +02:00
export {
ensureIsAdmin
}