]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/middlewares/admin.ts
Type functions
[github/Chocobozzz/PeerTube.git] / server / middlewares / admin.ts
CommitLineData
69818c93
C
1import 'express-validator'
2import * as express from 'express'
3
e02643f3 4import { logger } from '../helpers'
9bd26629 5
69818c93 6function ensureIsAdmin (req: express.Request, res: express.Response, next: express.NextFunction) {
9bd26629 7 const user = res.locals.oauth.token.user
ab683a8e 8 if (user.isAdmin() === false) {
9bd26629
C
9 logger.info('A non admin user is trying to access to an admin content.')
10 return res.sendStatus(403)
11 }
12
13 return next()
14}
15
16// ---------------------------------------------------------------------------
17
65fcc311
C
18export {
19 ensureIsAdmin
20}