diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-10 22:15:25 +0200 |
commit | 69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch) | |
tree | ad199a18ec3c322460d6f9523fc383ee562554e0 /server/middlewares/validators/users.ts | |
parent | 4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff) | |
download | PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.gz PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.tar.zst PeerTube-69818c9394366b954b6ba3bd697bd9d2b09f2a16.zip |
Type functions
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r-- | server/middlewares/validators/users.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index e0d1d917a..b7b9ef370 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -1,8 +1,11 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
1 | import { database as db } from '../../initializers/database' | 4 | import { database as db } from '../../initializers/database' |
2 | import { checkErrors } from './utils' | 5 | import { checkErrors } from './utils' |
3 | import { logger } from '../../helpers' | 6 | import { logger } from '../../helpers' |
4 | 7 | ||
5 | function usersAddValidator (req, res, next) { | 8 | function usersAddValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
6 | req.checkBody('username', 'Should have a valid username').isUserUsernameValid() | 9 | req.checkBody('username', 'Should have a valid username').isUserUsernameValid() |
7 | req.checkBody('password', 'Should have a valid password').isUserPasswordValid() | 10 | req.checkBody('password', 'Should have a valid password').isUserPasswordValid() |
8 | req.checkBody('email', 'Should have a valid email').isEmail() | 11 | req.checkBody('email', 'Should have a valid email').isEmail() |
@@ -23,7 +26,7 @@ function usersAddValidator (req, res, next) { | |||
23 | }) | 26 | }) |
24 | } | 27 | } |
25 | 28 | ||
26 | function usersRemoveValidator (req, res, next) { | 29 | function usersRemoveValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
27 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() | 30 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() |
28 | 31 | ||
29 | logger.debug('Checking usersRemove parameters', { parameters: req.params }) | 32 | logger.debug('Checking usersRemove parameters', { parameters: req.params }) |
@@ -44,7 +47,7 @@ function usersRemoveValidator (req, res, next) { | |||
44 | }) | 47 | }) |
45 | } | 48 | } |
46 | 49 | ||
47 | function usersUpdateValidator (req, res, next) { | 50 | function usersUpdateValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
48 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() | 51 | req.checkParams('id', 'Should have a valid id').notEmpty().isInt() |
49 | // Add old password verification | 52 | // Add old password verification |
50 | req.checkBody('password', 'Should have a valid password').optional().isUserPasswordValid() | 53 | req.checkBody('password', 'Should have a valid password').optional().isUserPasswordValid() |
@@ -55,7 +58,7 @@ function usersUpdateValidator (req, res, next) { | |||
55 | checkErrors(req, res, next) | 58 | checkErrors(req, res, next) |
56 | } | 59 | } |
57 | 60 | ||
58 | function usersVideoRatingValidator (req, res, next) { | 61 | function usersVideoRatingValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
59 | req.checkParams('videoId', 'Should have a valid video id').notEmpty().isUUID(4) | 62 | req.checkParams('videoId', 'Should have a valid video id').notEmpty().isUUID(4) |
60 | 63 | ||
61 | logger.debug('Checking usersVideoRating parameters', { parameters: req.params }) | 64 | logger.debug('Checking usersVideoRating parameters', { parameters: req.params }) |