X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=server%2Fmiddlewares%2Fvalidators%2Fusers.ts;h=a4d4ae46d0a1f5980ec3ab41e602e811f969976f;hb=d1ab89deb79f70c439b58750d044d9cadf1194e5;hp=7a081af33c266ceef1bec7551e9180997f14e912;hpb=1d5342abc43df02cf0bd69b1e865c0f179182eef;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 7a081af33..a4d4ae46d 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -27,7 +27,6 @@ import { areValidationErrors } from './utils' import { ActorModel } from '../../models/activitypub/actor' import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' -import { UserCreate } from '../../../shared/models/users' import { UserRegister } from '../../../shared/models/users/user-register.model' const usersAddValidator = [ @@ -53,8 +52,16 @@ const usersRegisterValidator = [ body('username').custom(isUserUsernameValid).withMessage('Should have a valid username'), body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'), body('email').isEmail().withMessage('Should have a valid email'), - body('channel.name').optional().custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), - body('channel.displayName').optional().custom(isVideoChannelNameValid).withMessage('Should have a valid display name'), + body('displayName') + .optional() + .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'), + + body('channel.name') + .optional() + .custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), + body('channel.displayName') + .optional() + .custom(isVideoChannelNameValid).withMessage('Should have a valid display name'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') }) @@ -170,13 +177,27 @@ const usersUpdateValidator = [ ] const usersUpdateMeValidator = [ - body('displayName').optional().custom(isUserDisplayNameValid).withMessage('Should have a valid display name'), - body('description').optional().custom(isUserDescriptionValid).withMessage('Should have a valid description'), - body('currentPassword').optional().custom(isUserPasswordValid).withMessage('Should have a valid current password'), - body('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'), - body('email').optional().isEmail().withMessage('Should have a valid email attribute'), - body('nsfwPolicy').optional().custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'), - body('autoPlayVideo').optional().custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'), + body('displayName') + .optional() + .custom(isUserDisplayNameValid).withMessage('Should have a valid display name'), + body('description') + .optional() + .custom(isUserDescriptionValid).withMessage('Should have a valid description'), + body('currentPassword') + .optional() + .custom(isUserPasswordValid).withMessage('Should have a valid current password'), + body('password') + .optional() + .custom(isUserPasswordValid).withMessage('Should have a valid password'), + body('email') + .optional() + .isEmail().withMessage('Should have a valid email attribute'), + body('nsfwPolicy') + .optional() + .custom(isUserNSFWPolicyValid).withMessage('Should have a valid display Not Safe For Work policy'), + body('autoPlayVideo') + .optional() + .custom(isUserAutoPlayVideoValid).withMessage('Should have a valid automatically plays video attribute'), body('videosHistoryEnabled') .optional() .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), @@ -321,8 +342,14 @@ const usersAskSendVerifyEmailValidator = [ ] const usersVerifyEmailValidator = [ - param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), - body('verificationString').not().isEmpty().withMessage('Should have a valid verification string'), + param('id') + .isInt().not().isEmpty().withMessage('Should have a valid id'), + + body('verificationString') + .not().isEmpty().withMessage('Should have a valid verification string'), + body('isPendingEmail') + .optional() + .toBoolean(), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking usersVerifyEmail parameters', { parameters: req.params })