diff options
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.ts | 35 |
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 @@ | |||
1 | import { Component, OnDestroy, OnInit, Input } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import * as generator from 'generate-password-browser' | ||
4 | import { NotificationsService } from 'angular2-notifications' | ||
5 | import { UserService } from '@app/shared/users/user.service' | 3 | import { UserService } from '@app/shared/users/user.service' |
6 | import { ServerService } from '../../../core' | 4 | import { Notifier } from '../../../core' |
7 | import { User, UserUpdate } from '../../../../../../shared' | 5 | import { User, UserUpdate } from '../../../../../../shared' |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
9 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 7 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
10 | import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' | 8 | import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' |
11 | import { ConfigService } from '@app/+admin/config/shared/config.service' | ||
12 | import { FormReactive } from '../../../shared' | 9 | import { 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 | }) |
19 | export class UserPasswordComponent extends FormReactive implements OnInit, OnDestroy { | 16 | export 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 | } |