diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-17 10:27:00 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-17 10:27:00 +0100 |
commit | 4c1c17093461b58d3ee3f23f239e340d8dac1149 (patch) | |
tree | 236b724f1415a812a4274fd63b519124cba2e42f /server/helpers/custom-validators/users.ts | |
parent | 45f1bd72a08998c60a9dd68ff069cea9de39161c (diff) | |
download | PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.tar.gz PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.tar.zst PeerTube-4c1c17093461b58d3ee3f23f239e340d8dac1149.zip |
Refactor email enabled function
Diffstat (limited to 'server/helpers/custom-validators/users.ts')
-rw-r--r-- | server/helpers/custom-validators/users.ts | 7 |
1 files changed, 3 insertions, 4 deletions
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' | |||
3 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' | 3 | import { CONSTRAINTS_FIELDS, NSFW_POLICY_TYPES } from '../../initializers/constants' |
4 | import { exists, isArray, isBooleanValid, isFileValid } from './misc' | 4 | import { exists, isArray, isBooleanValid, isFileValid } from './misc' |
5 | import { values } from 'lodash' | 5 | import { values } from 'lodash' |
6 | import { CONFIG } from '../../initializers/config' | 6 | import { isEmailEnabled } from '../../initializers/config' |
7 | 7 | ||
8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS | 8 | const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS |
9 | 9 | ||
@@ -13,9 +13,8 @@ function isUserPasswordValid (value: string) { | |||
13 | 13 | ||
14 | function isUserPasswordValidOrEmpty (value: string) { | 14 | function isUserPasswordValidOrEmpty (value: string) { |
15 | // Empty password is only possible if emailing is enabled. | 15 | // Empty password is only possible if emailing is enabled. |
16 | if (value === '') { | 16 | if (value === '') return isEmailEnabled() |
17 | return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT | 17 | |
18 | } | ||
19 | return isUserPasswordValid(value) | 18 | return isUserPasswordValid(value) |
20 | } | 19 | } |
21 | 20 | ||