aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-10 22:15:25 +0200
commit69818c9394366b954b6ba3bd697bd9d2b09f2a16 (patch)
treead199a18ec3c322460d6f9523fc383ee562554e0 /server/middlewares/validators/users.ts
parent4d4e5cd4dca78480ec7f40e747f424cd107376a4 (diff)
downloadPeerTube-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.ts11
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 @@
1import 'express-validator'
2import * as express from 'express'
3
1import { database as db } from '../../initializers/database' 4import { database as db } from '../../initializers/database'
2import { checkErrors } from './utils' 5import { checkErrors } from './utils'
3import { logger } from '../../helpers' 6import { logger } from '../../helpers'
4 7
5function usersAddValidator (req, res, next) { 8function 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
26function usersRemoveValidator (req, res, next) { 29function 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
47function usersUpdateValidator (req, res, next) { 50function 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
58function usersVideoRatingValidator (req, res, next) { 61function 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 })