aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/users/user-edit/user-password.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/users/user-edit/user-password.component.ts')
-rw-r--r--client/src/app/+admin/users/user-edit/user-password.component.ts35
1 files changed, 5 insertions, 30 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-password.component.ts b/client/src/app/+admin/users/user-edit/user-password.component.ts
index 30cd21ccd..5b3040440 100644
--- a/client/src/app/+admin/users/user-edit/user-password.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-password.component.ts
@@ -1,14 +1,11 @@
1import { Component, OnDestroy, OnInit, Input } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import * as generator from 'generate-password-browser'
4import { NotificationsService } from 'angular2-notifications'
5import { UserService } from '@app/shared/users/user.service' 3import { UserService } from '@app/shared/users/user.service'
6import { ServerService } from '../../../core' 4import { Notifier } from '../../../core'
7import { User, UserUpdate } from '../../../../../../shared' 5import { User, UserUpdate } from '../../../../../../shared'
8import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 7import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
10import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' 8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
11import { ConfigService } from '@app/+admin/config/shared/config.service'
12import { FormReactive } from '../../../shared' 9import { FormReactive } from '../../../shared'
13 10
14@Component({ 11@Component({
@@ -16,7 +13,7 @@ import { FormReactive } from '../../../shared'
16 templateUrl: './user-password.component.html', 13 templateUrl: './user-password.component.html',
17 styleUrls: [ './user-password.component.scss' ] 14 styleUrls: [ './user-password.component.scss' ]
18}) 15})
19export class UserPasswordComponent extends FormReactive implements OnInit, OnDestroy { 16export class UserPasswordComponent extends FormReactive implements OnInit {
20 error: string 17 error: string
21 username: string 18 username: string
22 showPassword = false 19 showPassword = false
@@ -25,12 +22,10 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
25 22
26 constructor ( 23 constructor (
27 protected formValidatorService: FormValidatorService, 24 protected formValidatorService: FormValidatorService,
28 protected serverService: ServerService,
29 protected configService: ConfigService,
30 private userValidatorsService: UserValidatorsService, 25 private userValidatorsService: UserValidatorsService,
31 private route: ActivatedRoute, 26 private route: ActivatedRoute,
32 private router: Router, 27 private router: Router,
33 private notificationsService: NotificationsService, 28 private notifier: Notifier,
34 private userService: UserService, 29 private userService: UserService,
35 private i18n: I18n 30 private i18n: I18n
36 ) { 31 ) {
@@ -43,10 +38,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
43 }) 38 })
44 } 39 }
45 40
46 ngOnDestroy () {
47 //
48 }
49
50 formValidated () { 41 formValidated () {
51 this.error = undefined 42 this.error = undefined
52 43
@@ -54,8 +45,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
54 45
55 this.userService.updateUser(this.userId, userUpdate).subscribe( 46 this.userService.updateUser(this.userId, userUpdate).subscribe(
56 () => { 47 () => {
57 this.notificationsService.success( 48 this.notifier.success(
58 this.i18n('Success'),
59 this.i18n('Password changed for user {{username}}.', { username: this.username }) 49 this.i18n('Password changed for user {{username}}.', { username: this.username })
60 ) 50 )
61 }, 51 },
@@ -64,16 +54,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
64 ) 54 )
65 } 55 }
66 56
67 generatePassword () {
68 this.form.patchValue({
69 password: generator.generate({
70 length: 16,
71 excludeSimilarCharacters: true,
72 strict: true
73 })
74 })
75 }
76
77 togglePasswordVisibility () { 57 togglePasswordVisibility () {
78 this.showPassword = !this.showPassword 58 this.showPassword = !this.showPassword
79 } 59 }
@@ -81,9 +61,4 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
81 getFormButtonTitle () { 61 getFormButtonTitle () {
82 return this.i18n('Update user password') 62 return this.i18n('Update user password')
83 } 63 }
84
85 private onUserFetched (userJson: User) {
86 this.userId = userJson.id
87 this.username = userJson.username
88 }
89} 64}