1 import { Component, OnInit } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { FormReactive, USER_PASSWORD, UserService } from '../../../shared'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
8 selector: 'my-account-change-password',
9 templateUrl: './my-account-change-password.component.html',
10 styleUrls: [ './my-account-change-password.component.scss' ]
12 export class MyAccountChangePasswordComponent extends FormReactive implements OnInit {
16 protected formValidatorService: FormValidatorService,
17 private notificationsService: NotificationsService,
18 private userService: UserService,
26 'new-password': USER_PASSWORD,
27 'new-confirmed-password': USER_PASSWORD
32 const newPassword = this.form.value['new-password']
33 const newConfirmedPassword = this.form.value['new-confirmed-password']
37 if (newPassword !== newConfirmedPassword) {
38 this.error = this.i18n('The new password and the confirmed password do not correspond.')
42 this.userService.changePassword(newPassword).subscribe(
43 () => this.notificationsService.success(this.i18n('Success'), this.i18n('Password updated.')),
45 err => this.error = err.message