]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/admin.ts
Type functions
[github/Chocobozzz/PeerTube.git] / server / middlewares / admin.ts
1 import 'express-validator'
2 import * as express from 'express'
3
4 import { logger } from '../helpers'
5
6 function ensureIsAdmin (req: express.Request, res: express.Response, next: express.NextFunction) {
7 const user = res.locals.oauth.token.user
8 if (user.isAdmin() === false) {
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
18 export {
19 ensureIsAdmin
20 }