1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Fix backend channel name validator consistency

This commit is contained in:
Chocobozzz 2021-08-05 13:54:35 +02:00
parent 352819ef92
commit 27db78400c
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 29 additions and 22 deletions

View file

@ -6,7 +6,6 @@ import { MUserDefault } from '@server/types/models'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { UserRole } from '../../../shared/models/users'
import { UserRegister } from '../../../shared/models/users/user-register.model'
import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
import {
@ -28,7 +27,7 @@ import {
isUserVideoQuotaValid,
isUserVideosHistoryEnabledValid
} from '../../helpers/custom-validators/users'
import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels'
import { isVideoChannelDisplayNameValid, isVideoChannelUsernameValid } from '../../helpers/custom-validators/video-channels'
import { logger } from '../../helpers/logger'
import { isThemeRegistered } from '../../lib/plugins/theme-utils'
import { Redis } from '../../lib/redis'
@ -56,9 +55,12 @@ const usersAddValidator = [
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
body('email').isEmail().withMessage('Should have a valid email'),
body('channelName').optional().custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
body('channelName').optional().custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
body('role')
.customSanitizer(toIntOrNull)
.custom(isUserRoleValid).withMessage('Should have a valid role'),
@ -106,10 +108,10 @@ const usersRegisterValidator = [
body('channel.name')
.optional()
.custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
.custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
body('channel.displayName')
.optional()
.custom(isVideoChannelNameValid).withMessage('Should have a valid display name'),
.custom(isVideoChannelDisplayNameValid).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') })