]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - admin.js
3288f4c6b9351ee89a8470bb13c4155e8a2dc65b
[github/Chocobozzz/PeerTube.git] / admin.js
1 'use strict'
2
3 const logger = require('../helpers/logger')
4
5 const adminMiddleware = {
6 ensureIsAdmin
7 }
8
9 function ensureIsAdmin (req, res, next) {
10 const user = res.locals.oauth.token.user
11 if (user.isAdmin() === false) {
12 logger.info('A non admin user is trying to access to an admin content.')
13 return res.sendStatus(403)
14 }
15
16 return next()
17 }
18
19 // ---------------------------------------------------------------------------
20
21 module.exports = adminMiddleware