aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/account.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-21 16:44:18 +0100
committerChocobozzz <me@florianbigard.com>2018-02-21 16:44:43 +0100
commite8cb44090e654fda339506dccfcec7fea8722723 (patch)
tree2a36d264cf44cededff0e272919316a3feabcbc1 /server/middlewares/validators/account.ts
parent276d03ed1a469fd4e3579f92392b6f9a1567d1ca (diff)
downloadPeerTube-e8cb44090e654fda339506dccfcec7fea8722723.tar.gz
PeerTube-e8cb44090e654fda339506dccfcec7fea8722723.tar.zst
PeerTube-e8cb44090e654fda339506dccfcec7fea8722723.zip
Add links to comment mentions
Diffstat (limited to 'server/middlewares/validators/account.ts')
-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}