aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/auth/auth.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-02-14 11:47:01 +0100
committerChocobozzz <me@florianbigard.com>2023-02-14 11:51:44 +0100
commit98bd5e2256bfdeba6d5ab07f0421acfde1a0de26 (patch)
treea1193f1af10f0da7a532d4aa6d5045e51c3d16a9 /client/src/app/core/auth/auth.service.ts
parent4ea827076df39935375d66fffb5e1e27e667111e (diff)
downloadPeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.tar.gz
PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.tar.zst
PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.zip
Refactor login redirection/button links
Correctly handle external auth redirection in all cases
Diffstat (limited to 'client/src/app/core/auth/auth.service.ts')
-rw-r--r--client/src/app/core/auth/auth.service.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index ed7eabb76..6fe601d8d 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -5,11 +5,11 @@ import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { Router } from '@angular/router' 6import { Router } from '@angular/router'
7import { Notifier } from '@app/core/notification/notifier.service' 7import { Notifier } from '@app/core/notification/notifier.service'
8import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage, PluginsManager } from '@root-helpers/index' 8import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index'
9import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' 9import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models'
10import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
11import { RestExtractor } from '../rest/rest-extractor.service' 11import { RestExtractor } from '../rest/rest-extractor.service'
12import { ServerService } from '../server' 12import { RedirectService } from '../routing'
13import { AuthStatus } from './auth-status.model' 13import { AuthStatus } from './auth-status.model'
14import { AuthUser } from './auth-user.model' 14import { AuthUser } from './auth-user.model'
15 15
@@ -45,7 +45,7 @@ export class AuthService {
45 private refreshingTokenObservable: Observable<any> 45 private refreshingTokenObservable: Observable<any>
46 46
47 constructor ( 47 constructor (
48 private serverService: ServerService, 48 private redirectService: RedirectService,
49 private http: HttpClient, 49 private http: HttpClient,
50 private notifier: Notifier, 50 private notifier: Notifier,
51 private hotkeysService: HotkeysService, 51 private hotkeysService: HotkeysService,
@@ -227,9 +227,7 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
227 logger.info('Cannot refresh token -> logout...') 227 logger.info('Cannot refresh token -> logout...')
228 this.logout() 228 this.logout()
229 229
230 const externalLoginUrl = PluginsManager.getDefaultLoginHref(environment.apiUrl, this.serverService.getHTMLConfig()) 230 this.redirectService.redirectToLogin()
231 if (externalLoginUrl) window.location.href = externalLoginUrl
232 else this.router.navigate([ '/login' ])
233 231
234 return observableThrowError(() => ({ 232 return observableThrowError(() => ({
235 error: $localize`You need to reconnect.` 233 error: $localize`You need to reconnect.`