Fix users update me param validation
This commit is contained in:
parent
afa4374ab4
commit
1a12adcd1e
|
@ -5,15 +5,16 @@ import { body, param } from 'express-validator/check'
|
||||||
import { omit } from 'lodash'
|
import { omit } from 'lodash'
|
||||||
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
|
import { isIdOrUUIDValid } from '../../helpers/custom-validators/misc'
|
||||||
import {
|
import {
|
||||||
isUserAutoPlayVideoValid, isUserBlockedReasonValid,
|
isUserAutoPlayVideoValid,
|
||||||
|
isUserBlockedReasonValid,
|
||||||
isUserDescriptionValid,
|
isUserDescriptionValid,
|
||||||
isUserDisplayNameValid,
|
isUserDisplayNameValid,
|
||||||
isUserNSFWPolicyValid,
|
isUserNSFWPolicyValid,
|
||||||
isUserPasswordValid,
|
isUserPasswordValid,
|
||||||
isUserRoleValid,
|
isUserRoleValid,
|
||||||
isUserUsernameValid,
|
isUserUsernameValid,
|
||||||
isUserVideoQuotaValid,
|
isUserVideoQuotaDailyValid,
|
||||||
isUserVideoQuotaDailyValid
|
isUserVideoQuotaValid, isUserVideosHistoryEnabledValid
|
||||||
} from '../../helpers/custom-validators/users'
|
} from '../../helpers/custom-validators/users'
|
||||||
import { isVideoExist } from '../../helpers/custom-validators/videos'
|
import { isVideoExist } from '../../helpers/custom-validators/videos'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
|
@ -22,7 +23,6 @@ import { Redis } from '../../lib/redis'
|
||||||
import { UserModel } from '../../models/account/user'
|
import { UserModel } from '../../models/account/user'
|
||||||
import { areValidationErrors } from './utils'
|
import { areValidationErrors } from './utils'
|
||||||
import { ActorModel } from '../../models/activitypub/actor'
|
import { ActorModel } from '../../models/activitypub/actor'
|
||||||
import { comparePassword } from '../../helpers/peertube-crypto'
|
|
||||||
|
|
||||||
const usersAddValidator = [
|
const usersAddValidator = [
|
||||||
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
|
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
|
||||||
|
@ -144,6 +144,9 @@ const usersUpdateMeValidator = [
|
||||||
body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
|
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('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('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'),
|
||||||
|
|
||||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||||
logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') })
|
logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') })
|
||||||
|
|
Loading…
Reference in New Issue