diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-21 16:44:18 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-21 16:44:43 +0100 |
commit | e8cb44090e654fda339506dccfcec7fea8722723 (patch) | |
tree | 2a36d264cf44cededff0e272919316a3feabcbc1 /server/middlewares | |
parent | 276d03ed1a469fd4e3579f92392b6f9a1567d1ca (diff) | |
download | PeerTube-e8cb44090e654fda339506dccfcec7fea8722723.tar.gz PeerTube-e8cb44090e654fda339506dccfcec7fea8722723.tar.zst PeerTube-e8cb44090e654fda339506dccfcec7fea8722723.zip |
Add links to comment mentions
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/account.ts | 23 |
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 @@ | |||
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 { isAccountIdExist, isAccountNameValid, isLocalAccountNameExist } from '../../helpers/custom-validators/accounts' | 3 | import { |
4 | isAccountIdExist, | ||
5 | isAccountNameValid, | ||
6 | isAccountNameWithHostExist, | ||
7 | isLocalAccountNameExist | ||
8 | } from '../../helpers/custom-validators/accounts' | ||
4 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' | 9 | import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' |
5 | import { logger } from '../../helpers/logger' | 10 | import { logger } from '../../helpers/logger' |
6 | import { areValidationErrors } from './utils' | 11 | import { areValidationErrors } from './utils' |
@@ -31,9 +36,23 @@ const accountsGetValidator = [ | |||
31 | } | 36 | } |
32 | ] | 37 | ] |
33 | 38 | ||
39 | const 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 | ||
36 | export { | 54 | export { |
37 | localAccountValidator, | 55 | localAccountValidator, |
38 | accountsGetValidator | 56 | accountsGetValidator, |
57 | accountsNameWithHostGetValidator | ||
39 | } | 58 | } |