aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+login/login.component.ts13
-rw-r--r--client/src/app/+manage/video-channel-edit/video-channel-update.component.ts2
-rw-r--r--client/src/app/core/routing/redirect.service.ts10
3 files changed, 18 insertions, 7 deletions
diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.ts
index 648b8db36..73bd41ab4 100644
--- a/client/src/app/+login/login.component.ts
+++ b/client/src/app/+login/login.component.ts
@@ -1,7 +1,7 @@
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 } from '@angular/router'
4import { AuthService, Notifier, RedirectService, 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'
7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' 7import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@@ -17,6 +17,8 @@ import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
17}) 17})
18 18
19export class LoginComponent extends FormReactive implements OnInit, AfterViewInit { 19export class LoginComponent extends FormReactive implements OnInit, AfterViewInit {
20 private static SESSION_STORAGE_REDIRECT_URL_KEY = 'login-previous-url'
21
20 @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef 22 @ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRef
21 23
22 accordion: NgbAccordion 24 accordion: NgbAccordion
@@ -46,7 +48,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
46 private userService: UserService, 48 private userService: UserService,
47 private redirectService: RedirectService, 49 private redirectService: RedirectService,
48 private notifier: Notifier, 50 private notifier: Notifier,
49 private hooks: HooksService 51 private hooks: HooksService,
52 private storage: SessionStorageService
50 ) { 53 ) {
51 super() 54 super()
52 } 55 }
@@ -88,6 +91,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIni
88 this.externalAuthError = true 91 this.externalAuthError = true
89 return 92 return
90 } 93 }
94
95 this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, this.redirectService.getPreviousUrl())
91 } 96 }
92 97
93 ngAfterViewInit () { 98 ngAfterViewInit () {
@@ -151,7 +156,9 @@ The link will expire within 1 hour.`
151 156
152 this.authService.login(username, null, token) 157 this.authService.login(username, null, token)
153 .subscribe({ 158 .subscribe({
154 next: () => this.redirectService.redirectToPreviousRoute(), 159 next: () => {
160 this.redirectService.redirectToPreviousRoute(this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY))
161 },
155 162
156 error: err => { 163 error: err => {
157 this.handleError(err) 164 this.handleError(err)
diff --git a/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts b/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts
index 51cd45605..6b4947912 100644
--- a/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts
+++ b/client/src/app/+manage/video-channel-edit/video-channel-update.component.ts
@@ -96,7 +96,7 @@ export class VideoChannelUpdateComponent extends VideoChannelEdit implements OnI
96 96
97 this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`) 97 this.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`)
98 98
99 this.redirectService.redirectToPreviousRoute([ '/c', this.videoChannel.name ]) 99 this.redirectService.redirectToPreviousRoute('/c/' + this.videoChannel.name)
100 }, 100 },
101 101
102 error: err => { 102 error: err => {
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 571476d1d..d4cb0436e 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -46,19 +46,23 @@ export class RedirectService {
46 return this.defaultTrendingAlgorithm 46 return this.defaultTrendingAlgorithm
47 } 47 }
48 48
49 redirectToPreviousRoute (fallbackRoute: string[] = null) { 49 getPreviousUrl () {
50 return this.previousUrl
51 }
52
53 redirectToPreviousRoute (fallbackRoute?: string) {
50 const exceptions = [ 54 const exceptions = [
51 '/verify-account', 55 '/verify-account',
52 '/reset-password' 56 '/reset-password'
53 ] 57 ]
54 58
55 if (this.previousUrl) { 59 if (this.previousUrl && this.previousUrl !== '/') {
56 const isException = exceptions.find(e => this.previousUrl.startsWith(e)) 60 const isException = exceptions.find(e => this.previousUrl.startsWith(e))
57 if (!isException) return this.router.navigateByUrl(this.previousUrl) 61 if (!isException) return this.router.navigateByUrl(this.previousUrl)
58 } 62 }
59 63
60 if (fallbackRoute) { 64 if (fallbackRoute) {
61 return this.router.navigate(fallbackRoute) 65 return this.router.navigateByUrl(fallbackRoute)
62 } 66 }
63 67
64 return this.redirectToHomepage() 68 return this.redirectToHomepage()