ActivityPub-federated video streaming platform using P2P directly in your web browser
Add URL redirection support for external auth
Chocobozzzcb28bb92daf1
diff --git a/client/src/app/+login/login.component.ts b/client/src/app/+login/login.component.tsindex 648b8db36a..73bd41ab4f 100644--- a/client/src/app/+login/login.component.ts+++ b/client/src/app/+login/login.component.ts@@ -1,7 +1,7 @@import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core'import { ActivatedRoute } from '@angular/router'-import { AuthService, Notifier, RedirectService, UserService } from '@app/core'+import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core'import { HooksService } from '@app/core/plugins/hooks.service'import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'@@ -17,6 +17,8 @@ import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'})export class LoginComponent extends FormReactive implements OnInit, AfterViewInit {+ private static SESSION_STORAGE_REDIRECT_URL_KEY = 'login-previous-url'+@ViewChild('forgotPasswordModal', { static: true }) forgotPasswordModal: ElementRefaccordion: NgbAccordion@@ -46,7 +48,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewIniprivate userService: UserService,private redirectService: RedirectService,private notifier: Notifier,- private hooks: HooksService+ private hooks: HooksService,+ private storage: SessionStorageService) {super()}@@ -88,6 +91,8 @@ export class LoginComponent extends FormReactive implements OnInit, AfterViewInithis.externalAuthError = truereturn}++ this.storage.setItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY, this.redirectService.getPreviousUrl())}ngAfterViewInit () {@@ -151,7 +156,9 @@ The link will expire within 1 hour.`this.authService.login(username, null, token).subscribe({- next: () => this.redirectService.redirectToPreviousRoute(),+ next: () => {+ this.redirectService.redirectToPreviousRoute(this.storage.getItem(LoginComponent.SESSION_STORAGE_REDIRECT_URL_KEY))+ },error: err => {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.tsindex 51cd456056..6b49479127 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 OnIthis.notifier.success($localize`Video channel ${videoChannelUpdate.displayName} updated.`)- this.redirectService.redirectToPreviousRoute([ '/c', this.videoChannel.name ])+ this.redirectService.redirectToPreviousRoute('/c/' + this.videoChannel.name)},error: err => {diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.tsindex 571476d1de..d4cb0436e5 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 {return this.defaultTrendingAlgorithm}- redirectToPreviousRoute (fallbackRoute: string[] = null) {+ getPreviousUrl () {+ return this.previousUrl+ }++ redirectToPreviousRoute (fallbackRoute?: string) {const exceptions = ['/verify-account','/reset-password']- if (this.previousUrl) {+ if (this.previousUrl && this.previousUrl !== '/') {const isException = exceptions.find(e => this.previousUrl.startsWith(e))if (!isException) return this.router.navigateByUrl(this.previousUrl)}if (fallbackRoute) {- return this.router.navigate(fallbackRoute)+ return this.router.navigateByUrl(fallbackRoute)}return this.redirectToHomepage()