X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fusers.ts;h=247b704c4331d8ff27c397220ec41de20d90303f;hb=fd4484f19eae8b0a0c30d5d30e98880c8708516a;hp=5f44c3b999874f1b5c58e58bbf76c0a769ba53f8;hpb=ecb4e35f4e6c7304cb274593c13cb47fd5078b75;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 5f44c3b99..247b704c4 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -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 }