aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/login
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/login')
-rw-r--r--client/src/app/login/login.component.html44
-rw-r--r--client/src/app/login/login.component.scss10
-rw-r--r--client/src/app/login/login.component.ts37
3 files changed, 85 insertions, 6 deletions
diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.html
index b61b66ec7..660a08280 100644
--- a/client/src/app/login/login.component.html
+++ b/client/src/app/login/login.component.html
@@ -19,10 +19,13 @@
19 19
20 <div class="form-group"> 20 <div class="form-group">
21 <label for="password">Password</label> 21 <label for="password">Password</label>
22 <input 22 <div>
23 type="password" name="password" id="password" placeholder="Password" required 23 <input
24 formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }" 24 type="password" name="password" id="password" placeholder="Password" required
25 > 25 formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
26 >
27 <div class="forgot-password-button" (click)="openForgotPasswordModal()">I forgot my password</div>
28 </div>
26 <div *ngIf="formErrors.password" class="form-error"> 29 <div *ngIf="formErrors.password" class="form-error">
27 {{ formErrors.password }} 30 {{ formErrors.password }}
28 </div> 31 </div>
@@ -31,3 +34,36 @@
31 <input type="submit" value="Login" [disabled]="!form.valid"> 34 <input type="submit" value="Login" [disabled]="!form.valid">
32 </form> 35 </form>
33</div> 36</div>
37
38<div bsModal #forgotPasswordModal="bs-modal" (onShown)="onForgotPasswordModalShown()" class="modal" tabindex="-1">
39 <div class="modal-dialog">
40 <div class="modal-content">
41
42 <div class="modal-header">
43 <span class="close" aria-hidden="true" (click)="hideForgotPasswordModal()"></span>
44 <h4 class="modal-title">Forgot your password</h4>
45 </div>
46
47 <div class="modal-body">
48 <div class="form-group">
49 <label for="forgot-password-email">Email</label>
50 <input
51 type="email" id="forgot-password-email" placeholder="Email address" required
52 [(ngModel)]="forgotPasswordEmail" #forgotPasswordEmailInput
53 >
54 </div>
55
56 <div class="form-group inputs">
57 <span class="action-button action-button-cancel" (click)="hideForgotPasswordModal()">
58 Cancel
59 </span>
60
61 <input
62 type="submit" value="Send me an email to reset my password" class="action-button-submit"
63 (click)="askResetPassword()" [disabled]="!forgotPasswordEmailInput.validity.valid"
64 >
65 </div>
66 </div>
67 </div>
68 </div>
69</div>
diff --git a/client/src/app/login/login.component.scss b/client/src/app/login/login.component.scss
index efec6b706..2cf6991ce 100644
--- a/client/src/app/login/login.component.scss
+++ b/client/src/app/login/login.component.scss
@@ -10,3 +10,13 @@ input[type=submit] {
10 @include peertube-button; 10 @include peertube-button;
11 @include orange-button; 11 @include orange-button;
12} 12}
13
14input[type=password] {
15 display: inline-block;
16 margin-right: 5px;
17}
18
19.forgot-password-button {
20 display: inline-block;
21 cursor: pointer;
22}
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}