]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/validators/users.ts
Cache AP video route for 5 seconds
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / users.ts
index 5f44c3b999874f1b5c58e58bbf76c0a769ba53f8..247b704c4331d8ff27c397220ec41de20d90303f 100644 (file)
@@ -7,7 +7,8 @@ import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
 import {
   isAvatarFile,
   isUserAutoPlayVideoValid,
-  isUserDisplayNSFWValid,
+  isUserDescriptionValid, isUserDisplayNameValid,
+  isUserNSFWPolicyValid,
   isUserPasswordValid,
   isUserRoleValid,
   isUserUsernameValid,
@@ -97,9 +98,11 @@ 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('password').optional().custom(isUserPasswordValid).withMessage('Should have a valid password'),
   body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
-  body('displayNSFW').optional().custom(isUserDisplayNSFWValid).withMessage('Should have a valid display Not Safe For Work 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'),
 
   (req: express.Request, res: express.Response, next: express.NextFunction) => {
@@ -210,7 +213,7 @@ const usersResetPasswordValidator = [
       return res
         .status(403)
         .send({ error: 'Invalid verification string.' })
-        .end
+        .end()
     }
 
     return next()
@@ -248,7 +251,7 @@ async function checkUserNameOrEmailDoesNotAlreadyExist (username: string, email:
 
   if (user) {
     res.status(409)
-              .send({ error: 'User with this username of email already exists.' })
+              .send({ error: 'User with this username or email already exists.' })
               .end()
     return false
   }