diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-14 11:47:01 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-14 11:51:44 +0100 |
commit | 98bd5e2256bfdeba6d5ab07f0421acfde1a0de26 (patch) | |
tree | a1193f1af10f0da7a532d4aa6d5045e51c3d16a9 /client/src/app/core/auth/auth.service.ts | |
parent | 4ea827076df39935375d66fffb5e1e27e667111e (diff) | |
download | PeerTube-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.ts | 10 |
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 | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
7 | import { Notifier } from '@app/core/notification/notifier.service' | 7 | import { Notifier } from '@app/core/notification/notifier.service' |
8 | import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage, PluginsManager } from '@root-helpers/index' | 8 | import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' |
9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' | 9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { RestExtractor } from '../rest/rest-extractor.service' | 11 | import { RestExtractor } from '../rest/rest-extractor.service' |
12 | import { ServerService } from '../server' | 12 | import { RedirectService } from '../routing' |
13 | import { AuthStatus } from './auth-status.model' | 13 | import { AuthStatus } from './auth-status.model' |
14 | import { AuthUser } from './auth-user.model' | 14 | import { 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.` |