aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-29 19:10:13 +0100
committerChocobozzz <me@florianbigard.com>2017-12-29 19:10:13 +0100
commitc5911fd347c76e8bdc05ea9f3ee9efed4a58c236 (patch)
treeb8d287daca6c45305090cbec9da97d1155f275bd /server/middlewares/validators/users.ts
parent8b0d42ee372de6589796be26b83e5bffb1b69cdf (diff)
downloadPeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.tar.gz
PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.tar.zst
PeerTube-c5911fd347c76e8bdc05ea9f3ee9efed4a58c236.zip
Begin to add avatar to actors
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r--server/middlewares/validators/users.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index db40a5c88..42ebddd56 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -3,12 +3,14 @@ import 'express-validator'
3import { body, param } from 'express-validator/check' 3import { body, param } from 'express-validator/check'
4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 4import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
5import { 5import {
6 isAvatarFile,
6 isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid, 7 isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid,
7 isUserVideoQuotaValid 8 isUserVideoQuotaValid
8} from '../../helpers/custom-validators/users' 9} from '../../helpers/custom-validators/users'
9import { isVideoExist } from '../../helpers/custom-validators/videos' 10import { isVideoExist, isVideoFile } from '../../helpers/custom-validators/videos'
10import { logger } from '../../helpers/logger' 11import { logger } from '../../helpers/logger'
11import { isSignupAllowed } from '../../helpers/utils' 12import { isSignupAllowed } from '../../helpers/utils'
13import { CONSTRAINTS_FIELDS } from '../../initializers'
12import { UserModel } from '../../models/account/user' 14import { UserModel } from '../../models/account/user'
13import { areValidationErrors } from './utils' 15import { areValidationErrors } from './utils'
14 16
@@ -96,6 +98,21 @@ const usersUpdateMeValidator = [
96 } 98 }
97] 99]
98 100
101const usersUpdateMyAvatarValidator = [
102 body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage(
103 'This file is not supported. Please, make sure it is of the following type : '
104 + CONSTRAINTS_FIELDS.ACTOR.AVATAR.EXTNAME.join(', ')
105 ),
106
107 (req: express.Request, res: express.Response, next: express.NextFunction) => {
108 logger.debug('Checking usersUpdateMyAvatarValidator parameters', { parameters: req.body })
109
110 if (areValidationErrors(req, res)) return
111
112 return next()
113 }
114]
115
99const usersGetValidator = [ 116const usersGetValidator = [
100 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 117 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
101 118
@@ -145,7 +162,8 @@ export {
145 usersUpdateMeValidator, 162 usersUpdateMeValidator,
146 usersVideoRatingValidator, 163 usersVideoRatingValidator,
147 ensureUserRegistrationAllowed, 164 ensureUserRegistrationAllowed,
148 usersGetValidator 165 usersGetValidator,
166 usersUpdateMyAvatarValidator
149} 167}
150 168
151// --------------------------------------------------------------------------- 169// ---------------------------------------------------------------------------