diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-09 10:47:46 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-09 10:47:46 +0200 |
commit | cb28bb92daf1a0e123bc0144030c2bc65b865f4a (patch) | |
tree | d8834a76b1e9a02316efc194b32d490db32daf24 /client/src/app/+login | |
parent | f82ea670d83dd7a02843b5ccc36ab1ce180a8d44 (diff) | |
download | PeerTube-cb28bb92daf1a0e123bc0144030c2bc65b865f4a.tar.gz PeerTube-cb28bb92daf1a0e123bc0144030c2bc65b865f4a.tar.zst PeerTube-cb28bb92daf1a0e123bc0144030c2bc65b865f4a.zip |
Add URL redirection support for external auth
Diffstat (limited to 'client/src/app/+login')
-rw-r--r-- | client/src/app/+login/login.component.ts | 13 |
1 files changed, 10 insertions, 3 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 | ||
2 | import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 2 | import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute } from '@angular/router' | 3 | import { ActivatedRoute } from '@angular/router' |
4 | import { AuthService, Notifier, RedirectService, UserService } from '@app/core' | 4 | import { AuthService, Notifier, RedirectService, SessionStorageService, UserService } from '@app/core' |
5 | import { HooksService } from '@app/core/plugins/hooks.service' | 5 | import { HooksService } from '@app/core/plugins/hooks.service' |
6 | import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' | 6 | import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators' |
7 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 7 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' |
@@ -17,6 +17,8 @@ import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models' | |||
17 | }) | 17 | }) |
18 | 18 | ||
19 | export class LoginComponent extends FormReactive implements OnInit, AfterViewInit { | 19 | export 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) |