diff options
Diffstat (limited to 'server/middlewares/validators/account.ts')
-rw-r--r-- | server/middlewares/validators/account.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/middlewares/validators/account.ts b/server/middlewares/validators/account.ts index 47ed6a7bb..70f4e4d3b 100644 --- a/server/middlewares/validators/account.ts +++ b/server/middlewares/validators/account.ts | |||
@@ -1,18 +1,19 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator/check' | 2 | import { param } from 'express-validator/check' |
3 | import { logger } from '../../helpers' | 3 | import { logger, isLocalAccountNameExist } from '../../helpers' |
4 | import { checkLocalAccountNameExists, isAccountNameValid } from '../../helpers/custom-validators/accounts' | 4 | import { isAccountNameValid } from '../../helpers/custom-validators/accounts' |
5 | import { checkErrors } from './utils' | 5 | import { areValidationErrors } from './utils' |
6 | 6 | ||
7 | const localAccountValidator = [ | 7 | const localAccountValidator = [ |
8 | param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), | 8 | param('name').custom(isAccountNameValid).withMessage('Should have a valid account name'), |
9 | 9 | ||
10 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 10 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
11 | logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) | 11 | logger.debug('Checking localAccountValidator parameters', { parameters: req.params }) |
12 | 12 | ||
13 | checkErrors(req, res, () => { | 13 | if (areValidationErrors(req, res)) return |
14 | checkLocalAccountNameExists(req.params.name, res, next) | 14 | if (!await isLocalAccountNameExist(req.params.name, res)) return |
15 | }) | 15 | |
16 | return next() | ||
16 | } | 17 | } |
17 | ] | 18 | ] |
18 | 19 | ||