aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-07-02 22:49:51 +0200
committerRigel Kent <sendmemail@rigelk.eu>2020-07-02 22:50:33 +0200
commit8491293b02ed2ec53eb0fa128161ea0b08d3def9 (patch)
treeb3d8dd2732f5876e39c73b7d917a7ad02f4e021a /server/middlewares/validators
parent2b587cad93381a1901df3c993bf1db90bbb0891f (diff)
downloadPeerTube-8491293b02ed2ec53eb0fa128161ea0b08d3def9.tar.gz
PeerTube-8491293b02ed2ec53eb0fa128161ea0b08d3def9.tar.zst
PeerTube-8491293b02ed2ec53eb0fa128161ea0b08d3def9.zip
add blocked filter in users list to filter banned users
fixes #2914
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/users.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 4a9ed6830..6860a3bed 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -38,6 +38,21 @@ import { UserRole } from '../../../shared/models/users'
38import { MUserDefault } from '@server/types/models' 38import { MUserDefault } from '@server/types/models'
39import { Hooks } from '@server/lib/plugins/hooks' 39import { Hooks } from '@server/lib/plugins/hooks'
40 40
41const usersListValidator = [
42 query('blocked')
43 .optional()
44 .customSanitizer(toBooleanOrNull)
45 .isBoolean().withMessage('Should be a valid boolean banned state'),
46
47 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 logger.debug('Checking usersList parameters', { parameters: req.query })
49
50 if (areValidationErrors(req, res)) return
51
52 return next()
53 }
54]
55
41const usersAddValidator = [ 56const usersAddValidator = [
42 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), 57 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
43 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'), 58 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
@@ -444,6 +459,7 @@ const ensureCanManageUser = [
444// --------------------------------------------------------------------------- 459// ---------------------------------------------------------------------------
445 460
446export { 461export {
462 usersListValidator,
447 usersAddValidator, 463 usersAddValidator,
448 deleteMeValidator, 464 deleteMeValidator,
449 usersRegisterValidator, 465 usersRegisterValidator,