1 import { Component, OnInit } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { FormReactive, UserService } from '../../../shared'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
6 import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
9 selector: 'my-account-change-password',
10 templateUrl: './my-account-change-password.component.html',
11 styleUrls: [ './my-account-change-password.component.scss' ]
13 export class MyAccountChangePasswordComponent extends FormReactive implements OnInit {
17 protected formValidatorService: FormValidatorService,
18 private userValidatorsService: UserValidatorsService,
19 private notificationsService: NotificationsService,
20 private userService: UserService,
28 'new-password': this.userValidatorsService.USER_PASSWORD,
29 'new-confirmed-password': this.userValidatorsService.USER_PASSWORD
34 const newPassword = this.form.value['new-password']
35 const newConfirmedPassword = this.form.value['new-confirmed-password']
39 if (newPassword !== newConfirmedPassword) {
40 this.error = this.i18n('The new password and the confirmed password do not correspond.')
44 this.userService.changePassword(newPassword).subscribe(
45 () => this.notificationsService.success(this.i18n('Success'), this.i18n('Password updated.')),
47 err => this.error = err.message