diff options
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/config.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/plugins.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 4 |
3 files changed, 9 insertions, 2 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index d015fa6fe..31b131914 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isUserNSFWPolicyValid, isUserVideoQuotaValid, isUserVideoQuotaDailyValid } from '../../helpers/custom-validators/users' | 3 | import { isUserNSFWPolicyValid, isUserVideoQuotaDailyValid, isUserVideoQuotaValid } from '../../helpers/custom-validators/users' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' |
6 | import { Emailer } from '../../lib/emailer' | 6 | import { Emailer } from '../../lib/emailer' |
7 | import { areValidationErrors } from './utils' | 7 | import { areValidationErrors } from './utils' |
8 | import { isThemeValid } from '../../helpers/custom-validators/plugins' | ||
8 | 9 | ||
9 | const customConfigUpdateValidator = [ | 10 | const customConfigUpdateValidator = [ |
10 | body('instance.name').exists().withMessage('Should have a valid instance name'), | 11 | body('instance.name').exists().withMessage('Should have a valid instance name'), |
@@ -47,6 +48,8 @@ const customConfigUpdateValidator = [ | |||
47 | body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), | 48 | body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), |
48 | body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), | 49 | body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), |
49 | 50 | ||
51 | body('theme.default').custom(isThemeValid).withMessage('Should have a valid theme'), | ||
52 | |||
50 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 53 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
51 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) | 54 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) |
52 | 55 | ||
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts index 672299ee1..fcb461624 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/middlewares/validators/plugins.ts | |||
@@ -16,7 +16,7 @@ const servePluginStaticDirectoryValidator = [ | |||
16 | 16 | ||
17 | if (areValidationErrors(req, res)) return | 17 | if (areValidationErrors(req, res)) return |
18 | 18 | ||
19 | const plugin = PluginManager.Instance.getRegisteredPlugin(req.params.pluginName) | 19 | const plugin = PluginManager.Instance.getRegisteredPluginOrTheme(req.params.pluginName) |
20 | 20 | ||
21 | if (!plugin || plugin.version !== req.params.pluginVersion) { | 21 | if (!plugin || plugin.version !== req.params.pluginVersion) { |
22 | return res.sendStatus(404) | 22 | return res.sendStatus(404) |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 947ed36c3..df7f77b84 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -28,6 +28,7 @@ import { ActorModel } from '../../models/activitypub/actor' | |||
28 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' | 28 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' |
29 | import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' | 29 | import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' |
30 | import { UserRegister } from '../../../shared/models/users/user-register.model' | 30 | import { UserRegister } from '../../../shared/models/users/user-register.model' |
31 | import { isThemeValid } from '../../helpers/custom-validators/plugins' | ||
31 | 32 | ||
32 | const usersAddValidator = [ | 33 | const usersAddValidator = [ |
33 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), | 34 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), |
@@ -204,6 +205,9 @@ const usersUpdateMeValidator = [ | |||
204 | body('videosHistoryEnabled') | 205 | body('videosHistoryEnabled') |
205 | .optional() | 206 | .optional() |
206 | .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), | 207 | .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), |
208 | body('theme') | ||
209 | .optional() | ||
210 | .custom(isThemeValid).withMessage('Should have a valid theme'), | ||
207 | 211 | ||
208 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 212 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
209 | logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') }) | 213 | logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') }) |