mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
First typescript iteration
This commit is contained in:
parent
d5f345ed4c
commit
65fcc3119c
113 changed files with 1961 additions and 1784 deletions
17
server/middlewares/admin.ts
Normal file
17
server/middlewares/admin.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
const logger = require('../helpers/logger')
|
||||
|
||||
function ensureIsAdmin (req, res, next) {
|
||||
const user = res.locals.oauth.token.user
|
||||
if (user.isAdmin() === false) {
|
||||
logger.info('A non admin user is trying to access to an admin content.')
|
||||
return res.sendStatus(403)
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
ensureIsAdmin
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue