mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Creating a user with an empty password will send an email to let him set his password (#2479)
* Creating a user with an empty password will send an email to let him set his password * Consideration of Chocobozzz's comments * Tips for optional password * API documentation * Fix circular imports * Tests
This commit is contained in:
parent
c5621bd23b
commit
45f1bd72a0
14 changed files with 201 additions and 18 deletions
|
@ -3,6 +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'
|
||||
|
||||
const USERS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.USERS
|
||||
|
||||
|
@ -10,6 +11,14 @@ function isUserPasswordValid (value: string) {
|
|||
return validator.isLength(value, USERS_CONSTRAINTS_FIELDS.PASSWORD)
|
||||
}
|
||||
|
||||
function isUserPasswordValidOrEmpty (value: string) {
|
||||
// Empty password is only possible if emailing is enabled.
|
||||
if (value === '') {
|
||||
return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT
|
||||
}
|
||||
return isUserPasswordValid(value)
|
||||
}
|
||||
|
||||
function isUserVideoQuotaValid (value: string) {
|
||||
return exists(value) && validator.isInt(value + '', USERS_CONSTRAINTS_FIELDS.VIDEO_QUOTA)
|
||||
}
|
||||
|
@ -103,6 +112,7 @@ export {
|
|||
isUserVideosHistoryEnabledValid,
|
||||
isUserBlockedValid,
|
||||
isUserPasswordValid,
|
||||
isUserPasswordValidOrEmpty,
|
||||
isUserVideoLanguages,
|
||||
isUserBlockedReasonValid,
|
||||
isUserRoleValid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue