1 import { Component, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { Notifier, UserService } from '@app/core'
4 import { FormReactive, FormValidatorService, ResetPasswordValidatorsService, UserValidatorsService } from '@app/shared/shared-forms'
8 templateUrl: './reset-password.component.html',
9 styleUrls: [ './reset-password.component.scss' ]
12 export class ResetPasswordComponent extends FormReactive implements OnInit {
13 private userId: number
14 private verificationString: string
17 protected formValidatorService: FormValidatorService,
18 private resetPasswordValidatorsService: ResetPasswordValidatorsService,
19 private userValidatorsService: UserValidatorsService,
20 private userService: UserService,
21 private notifier: Notifier,
22 private router: Router,
23 private route: ActivatedRoute
30 password: this.userValidatorsService.USER_PASSWORD,
31 'password-confirm': this.resetPasswordValidatorsService.RESET_PASSWORD_CONFIRM
34 this.userId = this.route.snapshot.queryParams['userId']
35 this.verificationString = this.route.snapshot.queryParams['verificationString']
37 if (!this.userId || !this.verificationString) {
38 this.notifier.error($localize`Unable to find user id or verification string.`)
39 this.router.navigate([ '/' ])
44 this.userService.resetPassword(this.userId, this.verificationString, this.form.value.password)
47 this.notifier.success($localize`Your password has been successfully reset!`)
48 this.router.navigate([ '/login' ])
51 err => this.notifier.error(err.message)
55 isConfirmedPasswordValid () {
56 const values = this.form.value
57 return values.password === values['password-confirm']