1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Refactor email enabled function

This commit is contained in:
Chocobozzz 2020-02-17 10:27:00 +01:00
parent 45f1bd72a0
commit 4c1c170934
No known key found for this signature in database
GPG key ID: 583A612D890159BE
11 changed files with 37 additions and 47 deletions

View file

@ -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)
}