diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 17:30:46 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:43:01 +0100 |
commit | a2431b7dcbc72c05101dcdbe631ff84a823aeb51 (patch) | |
tree | 09278a822905622a70ff976a75e09d99bc45639a /server/middlewares/validators/activitypub/signature.ts | |
parent | fcaf1e0aa84213a1b1f1b1a44a3276eae35ebe70 (diff) | |
download | PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.gz PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.tar.zst PeerTube-a2431b7dcbc72c05101dcdbe631ff84a823aeb51.zip |
Refractor validators
Diffstat (limited to 'server/middlewares/validators/activitypub/signature.ts')
-rw-r--r-- | server/middlewares/validators/activitypub/signature.ts | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/server/middlewares/validators/activitypub/signature.ts b/server/middlewares/validators/activitypub/signature.ts index 0ce15c1f6..360685512 100644 --- a/server/middlewares/validators/activitypub/signature.ts +++ b/server/middlewares/validators/activitypub/signature.ts | |||
@@ -1,14 +1,7 @@ | |||
1 | import { body } from 'express-validator/check' | ||
2 | import * as express from 'express' | 1 | import * as express from 'express' |
3 | 2 | import { body } from 'express-validator/check' | |
4 | import { | 3 | import { isDateValid, isSignatureCreatorValid, isSignatureTypeValid, isSignatureValueValid, logger } from '../../../helpers' |
5 | logger, | 4 | import { areValidationErrors } from '../utils' |
6 | isDateValid, | ||
7 | isSignatureTypeValid, | ||
8 | isSignatureCreatorValid, | ||
9 | isSignatureValueValid | ||
10 | } from '../../../helpers' | ||
11 | import { checkErrors } from '../utils' | ||
12 | 5 | ||
13 | const signatureValidator = [ | 6 | const signatureValidator = [ |
14 | body('signature.type').custom(isSignatureTypeValid).withMessage('Should have a valid signature type'), | 7 | body('signature.type').custom(isSignatureTypeValid).withMessage('Should have a valid signature type'), |
@@ -19,7 +12,9 @@ const signatureValidator = [ | |||
19 | (req: express.Request, res: express.Response, next: express.NextFunction) => { | 12 | (req: express.Request, res: express.Response, next: express.NextFunction) => { |
20 | logger.debug('Checking activitypub signature parameter', { parameters: { signature: req.body.signature } }) | 13 | logger.debug('Checking activitypub signature parameter', { parameters: { signature: req.body.signature } }) |
21 | 14 | ||
22 | checkErrors(req, res, next) | 15 | if (areValidationErrors(req, res)) return |
16 | |||
17 | return next() | ||
23 | } | 18 | } |
24 | ] | 19 | ] |
25 | 20 | ||