From 576ad67aaccf713b2a923deb3cb9b2a990613985 Mon Sep 17 00:00:00 2001 From: Josh Morel Date: Sun, 17 Feb 2019 13:14:00 -0500 Subject: check email enabled for requiresEmailVer config --- server/middlewares/validators/config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 90108fa82..270ce66f6 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts @@ -2,6 +2,8 @@ import * as express from 'express' import { body } from 'express-validator/check' import { isUserNSFWPolicyValid, isUserVideoQuotaValid, isUserVideoQuotaDailyValid } from '../../helpers/custom-validators/users' import { logger } from '../../helpers/logger' +import { CustomConfig } from '../../../shared/models/server/custom-config.model' +import { Emailer } from '../../lib/emailer' import { areValidationErrors } from './utils' const customConfigUpdateValidator = [ @@ -46,11 +48,27 @@ const customConfigUpdateValidator = [ logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) if (areValidationErrors(req, res)) return + if (!checkInvalidConfigIfEmailDisabled(req.body as CustomConfig, res)) return return next() } ] +// --------------------------------------------------------------------------- + export { customConfigUpdateValidator } + +function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: express.Response) { + if (Emailer.isEnabled()) return true + + if (customConfig.signup.requiresEmailVerification === true) { + res.status(400) + .send({ error: 'Emailer is disabled but you require signup email verification.' }) + .end() + return false + } + + return true +} -- cgit v1.2.3