aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/account/account.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/account/account.component.ts')
-rw-r--r--client/src/app/account/account.component.ts22
1 files changed, 13 insertions, 9 deletions
diff --git a/client/src/app/account/account.component.ts b/client/src/app/account/account.component.ts
index 5c42103f8..54939f43b 100644
--- a/client/src/app/account/account.component.ts
+++ b/client/src/app/account/account.component.ts
@@ -1,5 +1,6 @@
1import { Control, ControlGroup, Validators } from '@angular/common'; 1import { Validators } from '@angular/common';
2import { Component, OnInit } from '@angular/core'; 2import { Component, OnInit } from '@angular/core';
3import { FormControl, FormGroup, REACTIVE_FORM_DIRECTIVES } from '@angular/forms';
3import { Router } from '@angular/router'; 4import { Router } from '@angular/router';
4 5
5import { AccountService } from './account.service'; 6import { AccountService } from './account.service';
@@ -7,11 +8,14 @@ import { AccountService } from './account.service';
7@Component({ 8@Component({
8 selector: 'my-account', 9 selector: 'my-account',
9 template: require('./account.component.html'), 10 template: require('./account.component.html'),
10 providers: [ AccountService ] 11 providers: [ AccountService ],
12 directives: [ REACTIVE_FORM_DIRECTIVES ]
11}) 13})
12 14
13export class AccountComponent implements OnInit { 15export class AccountComponent implements OnInit {
14 changePasswordForm: ControlGroup; 16 newPassword = '';
17 newConfirmedPassword = '';
18 changePasswordForm: FormGroup;
15 information: string = null; 19 information: string = null;
16 error: string = null; 20 error: string = null;
17 21
@@ -21,22 +25,22 @@ export class AccountComponent implements OnInit {
21 ) {} 25 ) {}
22 26
23 ngOnInit() { 27 ngOnInit() {
24 this.changePasswordForm = new ControlGroup({ 28 this.changePasswordForm = new FormGroup({
25 newPassword: new Control('', Validators.compose([ Validators.required, Validators.minLength(6) ])), 29 'new-password': new FormControl('', [ <any>Validators.required, <any>Validators.minLength(6) ]),
26 newConfirmedPassword: new Control('', Validators.compose([ Validators.required, Validators.minLength(6) ])), 30 'new-confirmed-password': new FormControl('', [ <any>Validators.required, <any>Validators.minLength(6) ]),
27 }); 31 });
28 } 32 }
29 33
30 changePassword(newPassword: string, newConfirmedPassword: string) { 34 changePassword() {
31 this.information = null; 35 this.information = null;
32 this.error = null; 36 this.error = null;
33 37
34 if (newPassword !== newConfirmedPassword) { 38 if (this.newPassword !== this.newConfirmedPassword) {
35 this.error = 'The new password and the confirmed password do not correspond.'; 39 this.error = 'The new password and the confirmed password do not correspond.';
36 return; 40 return;
37 } 41 }
38 42
39 this.accountService.changePassword(newPassword).subscribe( 43 this.accountService.changePassword(this.newPassword).subscribe(
40 ok => this.information = 'Password updated.', 44 ok => this.information = 'Password updated.',
41 45
42 err => this.error = err 46 err => this.error = err