aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/login/login.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r--client/src/app/login/login.component.ts37
1 files changed, 35 insertions, 2 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts
index e7c9c7226..22e8c77dd 100644
--- a/client/src/app/login/login.component.ts
+++ b/client/src/app/login/login.component.ts
@@ -1,7 +1,9 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
2import { FormBuilder, FormGroup, Validators } from '@angular/forms' 2import { FormBuilder, FormGroup, Validators } from '@angular/forms'
3import { Router } from '@angular/router' 3import { Router } from '@angular/router'
4 4import { UserService } from '@app/shared'
5import { NotificationsService } from 'angular2-notifications'
6import { ModalDirective } from 'ngx-bootstrap/modal'
5import { AuthService } from '../core' 7import { AuthService } from '../core'
6import { FormReactive } from '../shared' 8import { FormReactive } from '../shared'
7 9
@@ -12,6 +14,9 @@ import { FormReactive } from '../shared'
12}) 14})
13 15
14export class LoginComponent extends FormReactive implements OnInit { 16export class LoginComponent extends FormReactive implements OnInit {
17 @ViewChild('forgotPasswordModal') forgotPasswordModal: ModalDirective
18 @ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef
19
15 error: string = null 20 error: string = null
16 21
17 form: FormGroup 22 form: FormGroup
@@ -27,9 +32,12 @@ export class LoginComponent extends FormReactive implements OnInit {
27 'required': 'Password is required.' 32 'required': 'Password is required.'
28 } 33 }
29 } 34 }
35 forgotPasswordEmail = ''
30 36
31 constructor ( 37 constructor (
32 private authService: AuthService, 38 private authService: AuthService,
39 private userService: UserService,
40 private notificationsService: NotificationsService,
33 private formBuilder: FormBuilder, 41 private formBuilder: FormBuilder,
34 private router: Router 42 private router: Router
35 ) { 43 ) {
@@ -60,4 +68,29 @@ export class LoginComponent extends FormReactive implements OnInit {
60 err => this.error = err.message 68 err => this.error = err.message
61 ) 69 )
62 } 70 }
71
72 askResetPassword () {
73 this.userService.askResetPassword(this.forgotPasswordEmail)
74 .subscribe(
75 res => {
76 const message = `An email with the reset password instructions will be sent to ${this.forgotPasswordEmail}.`
77 this.notificationsService.success('Success', message)
78 this.hideForgotPasswordModal()
79 },
80
81 err => this.notificationsService.error('Error', err.message)
82 )
83 }
84
85 onForgotPasswordModalShown () {
86 this.forgotPasswordEmailInput.nativeElement.focus()
87 }
88
89 openForgotPasswordModal () {
90 this.forgotPasswordModal.show()
91 }
92
93 hideForgotPasswordModal () {
94 this.forgotPasswordModal.hide()
95 }
63} 96}