Diagnostic tools: testing user rights.

This commit is contained in:
John Livingston
2021-04-10 13:57:47 +02:00
parent 80a51df1d5
commit 42bd94a8c3
2 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import type { Router, Request, Response, NextFunction } from 'express'
import { getBaseStaticRoute } from '../helpers'
import { getBaseStaticRoute, isUserAdmin } from '../helpers'
interface Result {
label?: string
@ -33,8 +33,9 @@ async function initSettingsRouter ({
if (!res.locals.authenticated) {
return res.sendStatus(403)
}
// FIXME: test that user is admin.
logger.error('FIXME: test that user is admin')
if (!isUserAdmin(res)) {
return res.sendStatus(403)
}
const test: string = req.body.test || ''
logger.info('Accessing peertube-plugin-livechat diagnostic tool, test "' + test + '".')