aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/reset-password
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-05 10:58:45 +0200
committerChocobozzz <me@florianbigard.com>2018-06-05 10:58:45 +0200
commitd18d64787b3ea174f7dc2740c8c8c9555625047e (patch)
treee65089e0ca81117c1ada981b9b8a524afa8d70f5 /client/src/app/reset-password
parent25acef90a85c1584880dec96aa402f896af8364a (diff)
downloadPeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.tar.gz
PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.tar.zst
PeerTube-d18d64787b3ea174f7dc2740c8c8c9555625047e.zip
Form validators refractoring
Diffstat (limited to 'client/src/app/reset-password')
-rw-r--r--client/src/app/reset-password/reset-password.component.ts31
1 files changed, 7 insertions, 24 deletions
diff --git a/client/src/app/reset-password/reset-password.component.ts b/client/src/app/reset-password/reset-password.component.ts
index c8bd368c1..58e086f45 100644
--- a/client/src/app/reset-password/reset-password.component.ts
+++ b/client/src/app/reset-password/reset-password.component.ts
@@ -1,11 +1,12 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup, Validators } from '@angular/forms'
3import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
4import { USER_PASSWORD, UserService } from '@app/shared' 3import { USER_PASSWORD, UserService } from '@app/shared'
5import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
6import { AuthService } from '../core' 5import { AuthService } from '../core'
7import { FormReactive } from '../shared' 6import { FormReactive } from '../shared'
8import { I18n } from '@ngx-translate/i18n-polyfill' 7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { RESET_PASSWORD_CONFIRM } from '@app/shared/forms/form-validators/reset-password'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
9 10
10@Component({ 11@Component({
11 selector: 'my-login', 12 selector: 'my-login',
@@ -14,26 +15,14 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
14}) 15})
15 16
16export class ResetPasswordComponent extends FormReactive implements OnInit { 17export class ResetPasswordComponent extends FormReactive implements OnInit {
17 form: FormGroup
18 formErrors = {
19 'password': '',
20 'password-confirm': ''
21 }
22 validationMessages = {
23 'password': USER_PASSWORD.MESSAGES,
24 'password-confirm': {
25 'required': 'Confirmation of the password is required.'
26 }
27 }
28
29 private userId: number 18 private userId: number
30 private verificationString: string 19 private verificationString: string
31 20
32 constructor ( 21 constructor (
22 protected formValidatorService: FormValidatorService,
33 private authService: AuthService, 23 private authService: AuthService,
34 private userService: UserService, 24 private userService: UserService,
35 private notificationsService: NotificationsService, 25 private notificationsService: NotificationsService,
36 private formBuilder: FormBuilder,
37 private router: Router, 26 private router: Router,
38 private route: ActivatedRoute, 27 private route: ActivatedRoute,
39 private i18n: I18n 28 private i18n: I18n
@@ -41,17 +30,11 @@ export class ResetPasswordComponent extends FormReactive implements OnInit {
41 super() 30 super()
42 } 31 }
43 32
44 buildForm () {
45 this.form = this.formBuilder.group({
46 password: [ '', USER_PASSWORD.VALIDATORS ],
47 'password-confirm': [ '', Validators.required ]
48 })
49
50 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
51 }
52
53 ngOnInit () { 33 ngOnInit () {
54 this.buildForm() 34 this.buildForm({
35 password: USER_PASSWORD,
36 'password-confirm': RESET_PASSWORD_CONFIRM
37 })
55 38
56 this.userId = this.route.snapshot.queryParams['userId'] 39 this.userId = this.route.snapshot.queryParams['userId']
57 this.verificationString = this.route.snapshot.queryParams['verificationString'] 40 this.verificationString = this.route.snapshot.queryParams['verificationString']