mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Implement user API (create, update, remove, list)
This commit is contained in:
parent
e4c556196d
commit
9bd2662976
16 changed files with 688 additions and 47 deletions
22
server/middlewares/admin.js
Normal file
22
server/middlewares/admin.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
'use strict'
|
||||
|
||||
const constants = require('../initializers/constants')
|
||||
const logger = require('../helpers/logger')
|
||||
|
||||
const adminMiddleware = {
|
||||
ensureIsAdmin: ensureIsAdmin
|
||||
}
|
||||
|
||||
function ensureIsAdmin (req, res, next) {
|
||||
const user = res.locals.oauth.token.user
|
||||
if (user.role !== constants.USER_ROLES.ADMIN) {
|
||||
logger.info('A non admin user is trying to access to an admin content.')
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = adminMiddleware
|
Loading…
Add table
Add a link
Reference in a new issue