aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-29 11:29:23 +0200
committerChocobozzz <me@florianbigard.com>2018-06-29 11:29:23 +0200
commit4bbfc6c606c8d3794bae25c64c516120af41f4eb (patch)
tree8d6012f3c04e55e7325e3f00eb9061776cc7a953 /server/middlewares/validators/users.ts
parent3ff5a19b4c988d6c712b7ce63c4cf04f99d047ce (diff)
downloadPeerTube-4bbfc6c606c8d3794bae25c64c516120af41f4eb.tar.gz
PeerTube-4bbfc6c606c8d3794bae25c64c516120af41f4eb.tar.zst
PeerTube-4bbfc6c606c8d3794bae25c64c516120af41f4eb.zip
API: Add ability to update video channel avatar
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r--server/middlewares/validators/users.ts21
1 files changed, 2 insertions, 19 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 55a08a648..8ca9763a1 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -5,9 +5,9 @@ import { body, param } from 'express-validator/check'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc' 6import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
7import { 7import {
8 isAvatarFile,
9 isUserAutoPlayVideoValid, 8 isUserAutoPlayVideoValid,
10 isUserDescriptionValid, isUserDisplayNameValid, 9 isUserDescriptionValid,
10 isUserDisplayNameValid,
11 isUserNSFWPolicyValid, 11 isUserNSFWPolicyValid,
12 isUserPasswordValid, 12 isUserPasswordValid,
13 isUserRoleValid, 13 isUserRoleValid,
@@ -17,7 +17,6 @@ import {
17import { isVideoExist } from '../../helpers/custom-validators/videos' 17import { isVideoExist } from '../../helpers/custom-validators/videos'
18import { logger } from '../../helpers/logger' 18import { logger } from '../../helpers/logger'
19import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/utils' 19import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/utils'
20import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers'
21import { Redis } from '../../lib/redis' 20import { Redis } from '../../lib/redis'
22import { UserModel } from '../../models/account/user' 21import { UserModel } from '../../models/account/user'
23import { areValidationErrors } from './utils' 22import { areValidationErrors } from './utils'
@@ -116,21 +115,6 @@ const usersUpdateMeValidator = [
116 } 115 }
117] 116]
118 117
119const usersUpdateMyAvatarValidator = [
120 body('avatarfile').custom((value, { req }) => isAvatarFile(req.files)).withMessage(
121 'This file is not supported or too large. Please, make sure it is of the following type : '
122 + CONSTRAINTS_FIELDS.ACTORS.AVATAR.EXTNAME.join(', ')
123 ),
124
125 (req: express.Request, res: express.Response, next: express.NextFunction) => {
126 logger.debug('Checking usersUpdateMyAvatarValidator parameters', { files: req.files })
127
128 if (areValidationErrors(req, res)) return
129
130 return next()
131 }
132]
133
134const usersGetValidator = [ 118const usersGetValidator = [
135 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 119 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
136 120
@@ -239,7 +223,6 @@ export {
239 ensureUserRegistrationAllowed, 223 ensureUserRegistrationAllowed,
240 ensureUserRegistrationAllowedForIP, 224 ensureUserRegistrationAllowedForIP,
241 usersGetValidator, 225 usersGetValidator,
242 usersUpdateMyAvatarValidator,
243 usersAskResetPasswordValidator, 226 usersAskResetPasswordValidator,
244 usersResetPasswordValidator 227 usersResetPasswordValidator
245} 228}