diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
commit | 88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch) | |
tree | b242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /client/src/app/login/login.component.ts | |
parent | 53a94c7cfa8368da4cd248d65df8346905938f0c (diff) | |
parent | 9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff) | |
download | PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip |
Merge branch 'develop' into pr/1217
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r-- | client/src/app/login/login.component.ts | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index 7553e6456..fc2442c0e 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
2 | import { RedirectService, ServerService } from '@app/core' | 2 | import { Notifier, RedirectService, ServerService } from '@app/core' |
3 | import { UserService } from '@app/shared' | 3 | import { UserService } from '@app/shared' |
4 | import { NotificationsService } from 'angular2-notifications' | ||
5 | import { AuthService } from '../core' | 4 | import { AuthService } from '../core' |
6 | import { FormReactive } from '../shared' | 5 | import { FormReactive } from '../shared' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -19,7 +18,6 @@ import { Router } from '@angular/router' | |||
19 | export class LoginComponent extends FormReactive implements OnInit { | 18 | export class LoginComponent extends FormReactive implements OnInit { |
20 | @ViewChild('emailInput') input: ElementRef | 19 | @ViewChild('emailInput') input: ElementRef |
21 | @ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef | 20 | @ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef |
22 | @ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef | ||
23 | 21 | ||
24 | error: string = null | 22 | error: string = null |
25 | forgotPasswordEmail = '' | 23 | forgotPasswordEmail = '' |
@@ -35,7 +33,7 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
35 | private userService: UserService, | 33 | private userService: UserService, |
36 | private serverService: ServerService, | 34 | private serverService: ServerService, |
37 | private redirectService: RedirectService, | 35 | private redirectService: RedirectService, |
38 | private notificationsService: NotificationsService, | 36 | private notifier: Notifier, |
39 | private i18n: I18n | 37 | private i18n: I18n |
40 | ) { | 38 | ) { |
41 | super() | 39 | super() |
@@ -45,6 +43,10 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
45 | return this.serverService.getConfig().signup.allowed === true | 43 | return this.serverService.getConfig().signup.allowed === true |
46 | } | 44 | } |
47 | 45 | ||
46 | isEmailDisabled () { | ||
47 | return this.serverService.getConfig().email.enabled === false | ||
48 | } | ||
49 | |||
48 | ngOnInit () { | 50 | ngOnInit () { |
49 | this.buildForm({ | 51 | this.buildForm({ |
50 | username: this.loginValidatorsService.LOGIN_USERNAME, | 52 | username: this.loginValidatorsService.LOGIN_USERNAME, |
@@ -61,7 +63,7 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
61 | 63 | ||
62 | this.authService.login(username, password) | 64 | this.authService.login(username, password) |
63 | .subscribe( | 65 | .subscribe( |
64 | () => this.redirect(), | 66 | () => this.redirectService.redirectToPreviousRoute(), |
65 | 67 | ||
66 | err => { | 68 | err => { |
67 | if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.') | 69 | if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.') |
@@ -71,15 +73,6 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
71 | ) | 73 | ) |
72 | } | 74 | } |
73 | 75 | ||
74 | redirect () { | ||
75 | const redirect = this.authService.redirectUrl | ||
76 | if (redirect) { | ||
77 | this.router.navigate([ redirect ]) | ||
78 | } else { | ||
79 | this.redirectService.redirectToHomepage() | ||
80 | } | ||
81 | } | ||
82 | |||
83 | askResetPassword () { | 76 | askResetPassword () { |
84 | this.userService.askResetPassword(this.forgotPasswordEmail) | 77 | this.userService.askResetPassword(this.forgotPasswordEmail) |
85 | .subscribe( | 78 | .subscribe( |
@@ -88,18 +81,14 @@ export class LoginComponent extends FormReactive implements OnInit { | |||
88 | 'An email with the reset password instructions will be sent to {{email}}.', | 81 | 'An email with the reset password instructions will be sent to {{email}}.', |
89 | { email: this.forgotPasswordEmail } | 82 | { email: this.forgotPasswordEmail } |
90 | ) | 83 | ) |
91 | this.notificationsService.success(this.i18n('Success'), message) | 84 | this.notifier.success(message) |
92 | this.hideForgotPasswordModal() | 85 | this.hideForgotPasswordModal() |
93 | }, | 86 | }, |
94 | 87 | ||
95 | err => this.notificationsService.error(this.i18n('Error'), err.message) | 88 | err => this.notifier.error(err.message) |
96 | ) | 89 | ) |
97 | } | 90 | } |
98 | 91 | ||
99 | onForgotPasswordModalShown () { | ||
100 | this.forgotPasswordEmailInput.nativeElement.focus() | ||
101 | } | ||
102 | |||
103 | openForgotPasswordModal () { | 92 | openForgotPasswordModal () { |
104 | this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal) | 93 | this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal) |
105 | } | 94 | } |