aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+login/login.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-05-20 11:43:04 +0200
committerChocobozzz <me@florianbigard.com>2022-05-20 11:43:04 +0200
commit13e7c3b02a265d2b8ecd1db65b0ae24fdfd620b4 (patch)
tree7feaa426b43ce07dad1a9312a6aa8834ac68361e /client/src/app/+login/login.component.ts
parent411c752529ed6c3fd7ac6e1922d4395c41fb0ded (diff)
downloadPeerTube-13e7c3b02a265d2b8ecd1db65b0ae24fdfd620b4.tar.gz
PeerTube-13e7c3b02a265d2b8ecd1db65b0ae24fdfd620b4.tar.zst
PeerTube-13e7c3b02a265d2b8ecd1db65b0ae24fdfd620b4.zip
Fix redirect users after login with external auth
Diffstat (limited to 'client/src/app/+login/login.component.ts')
-rw-r--r--client/src/app/+login/login.component.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts
index 73bd41ab4..96754b782 100644
--- a/client/src/app/+login/login.component.ts
+++ b/client/src/app/+login/login.component.ts
@@ -1,6 +1,6 @@
1 1
2import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' 2import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'
3import { ActivatedRoute } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core' 4import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core'
5import { HooksService } from '@app/core/plugins/hooks.service' 5import { HooksService } from '@app/core/plugins/hooks.service'
6import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' 6import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
@@ -49,7 +49,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
49 private redirectService: RedirectService, 49 private redirectService: RedirectService,
50 private notifier: Notifier, 50 private notifier: Notifier,
51 private hooks: HooksService, 51 private hooks: HooksService,
52 private storage: SessionStorageService 52 private storage: SessionStorageService,
53 private router: Router
53 ) { 54 ) {
54 super() 55 super()
55 } 56 }
@@ -92,7 +93,10 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
92 return 93 return
93 } 94 }
94 95
95 this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, this.redirectService.getPreviousUrl()) 96 const previousUrl = this.redirectService.getPreviousUrl()
97 if (previousUrl && previousUrl !== '/') {
98 this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, previousUrl)
99 }
96 } 100 }
97 101
98 ngAfterViewInit () { 102 ngAfterViewInit () {
@@ -157,7 +161,13 @@ The link will expire within 1 hour.`
157 this.authService.login(username, null, token) 161 this.authService.login(username, null, token)
158 .subscribe({ 162 .subscribe({
159 next: () => { 163 next: () => {
160 this.redirectService.redirectToPreviousRoute(this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY)) 164 const redirectUrl = this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY)
165 if (redirectUrl) {
166 this.storage.removeItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY)
167 return this.router.navigateByUrl(redirectUrl)
168 }
169
170 this.redirectService.redirectToLatestSessionRoute()
161 }, 171 },
162 172
163 error: err => { 173 error: err => {