From 503c6f440abc8f5924c38c4bd63591cb6cefacec Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 15 Jul 2019 15:41:56 +0200 Subject: Add peertube plugin index website models --- server/middlewares/validators/config.ts | 5 +++-- server/middlewares/validators/users.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 31b131914..9c43da165 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -5,7 +5,8 @@ import { logger } from '../../helpers/logger' import { CustomConfig } from '../../../shared/models/server/custom-config.model' import { Emailer } from '../../lib/emailer' import { areValidationErrors } from './utils' -import { isThemeValid } from '../../helpers/custom-validators/plugins' +import { isThemeNameValid } from '../../helpers/custom-validators/plugins' +import { isThemeRegistered } from '../../lib/plugins/theme-utils' const customConfigUpdateValidator = [ body('instance.name').exists().withMessage('Should have a valid instance name'), @@ -48,7 +49,7 @@ const customConfigUpdateValidator = [ body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), - body('theme.default').custom(isThemeValid).withMessage('Should have a valid theme'), + body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index df7f77b84..a507afc5b 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -28,7 +28,8 @@ import { ActorModel } from '../../models/activitypub/actor' import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' import { UserRegister } from '../../../shared/models/users/user-register.model' -import { isThemeValid } from '../../helpers/custom-validators/plugins' +import { isThemeNameValid } from '../../helpers/custom-validators/plugins' +import { isThemeRegistered } from '../../lib/plugins/theme-utils' const usersAddValidator = [ body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), @@ -207,7 +208,7 @@ const usersUpdateMeValidator = [ .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), body('theme') .optional() - .custom(isThemeValid).withMessage('Should have a valid theme'), + .custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), async (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') }) -- cgit v1.2.3