diff options
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r-- | server/middlewares/validators/users.ts | 16 |
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' | |||
38 | import { MUserDefault } from '@server/types/models' | 38 | import { MUserDefault } from '@server/types/models' |
39 | import { Hooks } from '@server/lib/plugins/hooks' | 39 | import { Hooks } from '@server/lib/plugins/hooks' |
40 | 40 | ||
41 | const 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 | |||
41 | const usersAddValidator = [ | 56 | const 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 | ||
446 | export { | 461 | export { |
462 | usersListValidator, | ||
447 | usersAddValidator, | 463 | usersAddValidator, |
448 | deleteMeValidator, | 464 | deleteMeValidator, |
449 | usersRegisterValidator, | 465 | usersRegisterValidator, |