]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/users.ts
Merge branch 'release/3.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / users.ts
index 63673bee217e2b07616a1824840cc31f6022b450..d6e91ad35df62351fe66720caf8c3b7b977ba030 100644 (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)
 }
 
@@ -47,7 +46,7 @@ function isUserEmailVerifiedValid (value: any) {
 
 const nsfwPolicies = values(NSFW_POLICY_TYPES)
 function isUserNSFWPolicyValid (value: any) {
-  return exists(value) && nsfwPolicies.indexOf(value) !== -1
+  return exists(value) && nsfwPolicies.includes(value)
 }
 
 function isUserWebTorrentEnabledValid (value: any) {