aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r--server/middlewares/validators/users.ts39
1 files changed, 29 insertions, 10 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index b4e09c9b7..a4d4ae46d 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -27,7 +27,6 @@ import { areValidationErrors } from './utils'
27import { ActorModel } from '../../models/activitypub/actor' 27import { ActorModel } from '../../models/activitypub/actor'
28import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' 28import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
29import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' 29import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels'
30import { UserCreate } from '../../../shared/models/users'
31import { UserRegister } from '../../../shared/models/users/user-register.model' 30import { UserRegister } from '../../../shared/models/users/user-register.model'
32 31
33const usersAddValidator = [ 32const usersAddValidator = [
@@ -178,13 +177,27 @@ const usersUpdateValidator = [
178] 177]
179 178
180const usersUpdateMeValidator = [ 179const usersUpdateMeValidator = [
181 body('displayName').optional().custom(isUserDisplayNameValid).withMessage('Should have a valid display name'), 180 body('displayName')
182 body('description').optional().custom(isUserDescriptionValid).withMessage('Should have a valid description'), 181 .optional()
183 body('currentPassword').optional().custom(isUserPasswordValid).withMessage('Should have a valid current password'), 182 .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'),
184 body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), 183 body('description')
185 body('email').optional().isEmail().withMessage('Should have a valid email attribute'), 184 .optional()
186 body('nsfwPolicy').optional().custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'), 185 .custom(isUserDescriptionValid).withMessage('Should have a valid description'),
187 body('autoPlayVideo').optional().custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'), 186 body('currentPassword')
187 .optional()
188 .custom(isUserPasswordValid).withMessage('Should have a valid current password'),
189 body('password')
190 .optional()
191 .custom(isUserPasswordValid).withMessage('Should have a valid password'),
192 body('email')
193 .optional()
194 .isEmail().withMessage('Should have a valid email attribute'),
195 body('nsfwPolicy')
196 .optional()
197 .custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'),
198 body('autoPlayVideo')
199 .optional()
200 .custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'),
188 body('videosHistoryEnabled') 201 body('videosHistoryEnabled')
189 .optional() 202 .optional()
190 .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), 203 .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'),
@@ -329,8 +342,14 @@ const usersAskSendVerifyEmailValidator = [
329] 342]
330 343
331const usersVerifyEmailValidator = [ 344const usersVerifyEmailValidator = [
332 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 345 param('id')
333 body('verificationString').not().isEmpty().withMessage('Should have a valid verification string'), 346 .isInt().not().isEmpty().withMessage('Should have a valid id'),
347
348 body('verificationString')
349 .not().isEmpty().withMessage('Should have a valid verification string'),
350 body('isPendingEmail')
351 .optional()
352 .toBoolean(),
334 353
335 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 354 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
336 logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params }) 355 logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })