From 4c1c17093461b58d3ee3f23f239e340d8dac1149 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Feb 2020 10:27:00 +0100 Subject: Refactor email enabled function --- server/helpers/custom-validators/users.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'server/helpers/custom-validators/users.ts') diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 63673bee2..1ddbe0815 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -3,7 +3,7 @@ import { UserRole } from '../../../shared' import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' import { exists, isArray, isBooleanValid, isFileValid } from './misc' import { values } from 'lodash' -import { CONFIG } from '../../initializers/config' +import { isEmailEnabled } from '../../initializers/config' const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS @@ -13,9 +13,8 @@ function isUserPasswordValid (value: string) { function isUserPasswordValidOrEmpty (value: string) { // Empty password is only possible if emailing is enabled. - if (value === '') { - return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT - } + if (value === '') return isEmailEnabled() + return isUserPasswordValid(value) } -- cgit v1.2.3