diff options
author | Chocobozzz <me@florianbigard.com> | 2019-06-11 11:54:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-06-11 14:31:11 +0200 |
commit | d1ab89deb79f70c439b58750d044d9cadf1194e5 (patch) | |
tree | 3cd18a0a8a3bf7497aec9d803c759bf54656115c /server/middlewares/validators/users.ts | |
parent | fff77ba23191f9bca959d5989a1f1df331dbac0b (diff) | |
download | PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.tar.gz PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.tar.zst PeerTube-d1ab89deb79f70c439b58750d044d9cadf1194e5.zip |
Handle email update on server
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r-- | server/middlewares/validators/users.ts | 39 |
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' | |||
27 | import { ActorModel } from '../../models/activitypub/actor' | 27 | import { ActorModel } from '../../models/activitypub/actor' |
28 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' | 28 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' |
29 | import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' | 29 | import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' |
30 | import { UserCreate } from '../../../shared/models/users' | ||
31 | import { UserRegister } from '../../../shared/models/users/user-register.model' | 30 | import { UserRegister } from '../../../shared/models/users/user-register.model' |
32 | 31 | ||
33 | const usersAddValidator = [ | 32 | const usersAddValidator = [ |
@@ -178,13 +177,27 @@ const usersUpdateValidator = [ | |||
178 | ] | 177 | ] |
179 | 178 | ||
180 | const usersUpdateMeValidator = [ | 179 | const 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 | ||
331 | const usersVerifyEmailValidator = [ | 344 | const 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 }) |