aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/account.ts23
1 files changed, 21 insertions, 2 deletions
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts
index ebc2fcf2d..0c4b7051d 100644
--- a/server/middlewares/validators/account.ts
+++ b/server/middlewares/validators/account.ts
@@ -1,6 +1,11 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator/check' 2import { param } from 'express-validator/check'
3import { isAccountIdExist, isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts' 3import {
4 isAccountIdExist,
5 isAccountNameValid,
6 isAccountNameWithHostExist,
7 isLocalAccountNameExist
8} from '../../helpers/custom-validators/accounts'
4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 9import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
5import { logger } from '../../helpers/logger' 10import { logger } from '../../helpers/logger'
6import { areValidationErrors } from './utils' 11import { areValidationErrors } from './utils'
@@ -31,9 +36,23 @@ const accountsGetValidator = [
31 } 36 }
32] 37]
33 38
39const accountsNameWithHostGetValidator = [
40 param('nameWithHost').exists().withMessage('Should have an account name with host'),
41
42 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
43 logger.debug('Checking accountsNameWithHostGetValidator parameters', { parameters: req.params })
44
45 if (areValidationErrors(req, res)) return
46 if (!await isAccountNameWithHostExist(req.params.nameWithHost, res)) return
47
48 return next()
49 }
50]
51
34// --------------------------------------------------------------------------- 52// ---------------------------------------------------------------------------
35 53
36export { 54export {
37 localAccountValidator, 55 localAccountValidator,
38 accountsGetValidator 56 accountsGetValidator,
57 accountsNameWithHostGetValidator
39} 58}