1 import { Component, Input, OnInit } from '@angular/core'
2 import { Notifier, UserService } from '@app/core'
3 import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
4 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
5 import { UserUpdate } from '@shared/models'
8 selector: 'my-user-password',
9 templateUrl: './user-password.component.html',
10 styleUrls: [ './user-password.component.scss' ]
12 export class UserPasswordComponent extends FormReactive implements OnInit {
17 @Input() userId: number
20 protected formValidatorService: FormValidatorService,
21 private notifier: Notifier,
22 private userService: UserService
29 password: USER_PASSWORD_VALIDATOR
34 this.error = undefined
36 const userUpdate: UserUpdate = this.form.value
38 this.userService.updateUser(this.userId, userUpdate).subscribe(
40 this.notifier.success($localize`Password changed for user ${this.username}.`)
43 err => this.error = err.message
47 togglePasswordVisibility () {
48 this.showPassword = !this.showPassword
51 getFormButtonTitle () {
52 return $localize`Update user password`