aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/login
diff options
context:
space:
mode:
authorBO41 <lukasw41@gmail.com>2018-09-23 16:37:48 +0200
committerRigel Kent <par@rigelk.eu>2018-09-23 16:37:48 +0200
commitec769c89fdcbcaf2d15de8d211d3ede3b6f69c1a (patch)
tree76ae11169ee75db87324a921f05572601f733196 /client/src/app/login
parent923406990334d133a49a283629322d1bbb521ecc (diff)
downloadPeerTube-ec769c89fdcbcaf2d15de8d211d3ede3b6f69c1a.tar.gz
PeerTube-ec769c89fdcbcaf2d15de8d211d3ede3b6f69c1a.tar.zst
PeerTube-ec769c89fdcbcaf2d15de8d211d3ede3b6f69c1a.zip
add redirect after login (#1110)
Diffstat (limited to 'client/src/app/login')
-rw-r--r--client/src/app/login/login.component.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts
index 4bae3ae5c..7553e6456 100644
--- a/client/src/app/login/login.component.ts
+++ b/client/src/app/login/login.component.ts
@@ -8,6 +8,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
9import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service' 9import { LoginValidatorsService } from '@app/shared/forms/form-validators/login-validators.service'
10import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' 10import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
11import { Router } from '@angular/router'
11 12
12@Component({ 13@Component({
13 selector: 'my-login', 14 selector: 'my-login',
@@ -26,6 +27,7 @@ export class LoginComponent extends FormReactive implements OnInit {
26 private openedForgotPasswordModal: NgbModalRef 27 private openedForgotPasswordModal: NgbModalRef
27 28
28 constructor ( 29 constructor (
30 public router: Router,
29 protected formValidatorService: FormValidatorService, 31 protected formValidatorService: FormValidatorService,
30 private modalService: NgbModal, 32 private modalService: NgbModal,
31 private loginValidatorsService: LoginValidatorsService, 33 private loginValidatorsService: LoginValidatorsService,
@@ -59,7 +61,7 @@ export class LoginComponent extends FormReactive implements OnInit {
59 61
60 this.authService.login(username, password) 62 this.authService.login(username, password)
61 .subscribe( 63 .subscribe(
62 () => this.redirectService.redirectToHomepage(), 64 () => this.redirect(),
63 65
64 err => { 66 err => {
65 if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.') 67 if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.')
@@ -69,6 +71,15 @@ export class LoginComponent extends FormReactive implements OnInit {
69 ) 71 )
70 } 72 }
71 73
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
72 askResetPassword () { 83 askResetPassword () {
73 this.userService.askResetPassword(this.forgotPasswordEmail) 84 this.userService.askResetPassword(this.forgotPasswordEmail)
74 .subscribe( 85 .subscribe(