update-password.component.ts
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Component, AfterViewInit, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import {ApplicationService} from '../services/application.service';
declare var jQuery: any;
@Component({
templateUrl: './app/components/update-password.component.html',
styles: [`
.child {
position: relative;
margin-left:20%;
margin-right:20%;
}
@media only screen and (max-width: 700px) {
.child {
margin-left: 0;
margin-right: 0;
}
}
`]
})
export class UpdatePasswordComponent implements AfterViewInit {
password: string;
confirmPassword: string;
isProcessing: boolean;
message: string;
isPasswordResetValidityExpired: boolean;
constructor(public application: ApplicationService, private router: Router, private activeRoute: ActivatedRoute) {
this.password = "";
this.confirmPassword = "";
this.message = "";
}
ngOnInit(): void {
this.application.isResetPasswordExpired(this.activeRoute.snapshot.params['userId']).subscribe((response) => {
if (!response.successful) {
this.isPasswordResetValidityExpired = true;
this.message = response.message;
setTimeout(() => {
this.router.navigate(['/login']);
}, 2000);
}
});;
}
ngAfterViewInit(): void {
jQuery('body').css("background-color", "brown");
}
updatePassword(): void {
this.isProcessing = true;
this.message = "";
if (this.password == this.confirmPassword) {
this.application.updatePassword(this.activeRoute.snapshot.params['userId'], this.password).subscribe((response) => {
if (response.successful) {
this.message = response.message;
this.isProcessing = false;
setTimeout(() => {
this.router.navigate(['/login']);
}, 2000);
}
});
}
}
}