diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-30 13:27:07 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-30 13:27:07 +0100 |
commit | ecb4e35f4e6c7304cb274593c13cb47fd5078b75 (patch) | |
tree | 1e238002340bc521afde59d52f406e41298a7aac /client/src/app/login/login.component.ts | |
parent | 80d1057bfcd3582af0dacf5ccd5a7a93ef95410b (diff) | |
download | PeerTube-ecb4e35f4e6c7304cb274593c13cb47fd5078b75.tar.gz PeerTube-ecb4e35f4e6c7304cb274593c13cb47fd5078b75.tar.zst PeerTube-ecb4e35f4e6c7304cb274593c13cb47fd5078b75.zip |
Add ability to reset our password
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r-- | client/src/app/login/login.component.ts | 37 |
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 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms' | 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms' |
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | 4 | import { UserService } from '@app/shared' | |
5 | import { NotificationsService } from 'angular2-notifications' | ||
6 | import { ModalDirective } from 'ngx-bootstrap/modal' | ||
5 | import { AuthService } from '../core' | 7 | import { AuthService } from '../core' |
6 | import { FormReactive } from '../shared' | 8 | import { FormReactive } from '../shared' |
7 | 9 | ||
@@ -12,6 +14,9 @@ import { FormReactive } from '../shared' | |||
12 | }) | 14 | }) |
13 | 15 | ||
14 | export class LoginComponent extends FormReactive implements OnInit { | 16 | export 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 | } |