From 45f1bd72a08998c60a9dd68ff069cea9de39161c Mon Sep 17 00:00:00 2001 From: John Livingston <38844060+JohnXLivingston@users.noreply.github.com> Date: Mon, 17 Feb 2020 10:16:52 +0100 Subject: 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 --- client/src/app/+admin/users/user-edit/user-create.component.ts | 10 ++++++++-- client/src/app/+admin/users/user-edit/user-edit.component.html | 7 +++++++ client/src/app/+admin/users/user-edit/user-update.component.ts | 4 ++++ client/src/app/+admin/users/users.routes.ts | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) (limited to 'client/src/app/+admin') diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts index e726ec4d7..1769c0de0 100644 --- a/client/src/app/+admin/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/users/user-edit/user-create.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core' -import { Router } from '@angular/router' +import { Router, ActivatedRoute } from '@angular/router' import { AuthService, Notifier, ServerService } from '@app/core' import { UserCreate, UserRole } from '../../../../../../shared' import { UserEdit } from './user-edit' @@ -23,6 +23,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { protected configService: ConfigService, protected auth: AuthService, private userValidatorsService: UserValidatorsService, + private route: ActivatedRoute, private router: Router, private notifier: Notifier, private userService: UserService, @@ -45,7 +46,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { this.buildForm({ username: this.userValidatorsService.USER_USERNAME, email: this.userValidatorsService.USER_EMAIL, - password: this.userValidatorsService.USER_PASSWORD, + password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD, role: this.userValidatorsService.USER_ROLE, videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY, @@ -78,6 +79,11 @@ export class UserCreateComponent extends UserEdit implements OnInit { return true } + isPasswordOptional () { + const serverConfig = this.route.snapshot.data.serverConfig + return serverConfig.email.enabled + } + getFormButtonTitle () { return this.i18n('Create user') } diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.html b/client/src/app/+admin/users/user-edit/user-edit.component.html index 4ff4d0d12..2aca5ddca 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.component.html +++ b/client/src/app/+admin/users/user-edit/user-edit.component.html @@ -29,6 +29,13 @@