X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fauth%2Fauth.service.ts;h=6fe601d8d24634275bfb0e555e3560d5aad07f3d;hb=98bd5e2256bfdeba6d5ab07f0421acfde1a0de26;hp=4de28e51e9d95ee53c969b882e53065a43e617ca;hpb=b1dbb9fefc870a90b25f5c0153589f45c9e75e3e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 4de28e51e..6fe601d8d 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -9,6 +9,7 @@ import { logger, OAuthUserTokens, objectToUrlEncoded, peertubeLocalStorage } fro import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' import { environment } from '../../../environments/environment' import { RestExtractor } from '../rest/rest-extractor.service' +import { RedirectService } from '../routing' import { AuthStatus } from './auth-status.model' import { AuthUser } from './auth-user.model' @@ -44,6 +45,7 @@ export class AuthService { private refreshingTokenObservable: Observable constructor ( + private redirectService: RedirectService, private http: HttpClient, private notifier: Notifier, private hotkeysService: HotkeysService, @@ -213,25 +215,26 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded') this.refreshingTokenObservable = this.http.post(AuthService.BASE_TOKEN_URL, body, { headers }) - .pipe( - map(res => this.handleRefreshToken(res)), - tap(() => { - this.refreshingTokenObservable = null - }), - catchError(err => { - this.refreshingTokenObservable = null - - logger.error(err) - logger.info('Cannot refresh token -> logout...') - this.logout() - this.router.navigate([ '/login' ]) - - return observableThrowError(() => ({ - error: $localize`You need to reconnect.` - })) - }), - share() - ) + .pipe( + map(res => this.handleRefreshToken(res)), + tap(() => { + this.refreshingTokenObservable = null + }), + catchError(err => { + this.refreshingTokenObservable = null + + logger.error(err) + logger.info('Cannot refresh token -> logout...') + this.logout() + + this.redirectService.redirectToLogin() + + return observableThrowError(() => ({ + error: $localize`You need to reconnect.` + })) + }), + share() + ) return this.refreshingTokenObservable }