]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/middlewares/admin.ts
require -> import
[github/Chocobozzz/PeerTube.git] / server / middlewares / admin.ts
... / ...
CommitLineData
1import { logger } from '../helpers'
2
3function 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
15export {
16 ensureIsAdmin
17}