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