From e887918077f5f7305f1ab7682440e8b465306211 Mon Sep 17 00:00:00 2001 From: ACX <8075870+acx10@users.noreply.github.com> Date: Fri, 6 Mar 2026 11:41:49 -0700 Subject: [PATCH] fix broken state when canceling OIDC logout at provider (#2082) (#3201) --- .../src/app/shared/components/login/login.component.ts | 2 ++ booklore-ui/src/app/shared/service/auth.service.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/booklore-ui/src/app/shared/components/login/login.component.ts b/booklore-ui/src/app/shared/components/login/login.component.ts index 9b3500f9a..283c9f596 100644 --- a/booklore-ui/src/app/shared/components/login/login.component.ts +++ b/booklore-ui/src/app/shared/components/login/login.component.ts @@ -54,6 +54,8 @@ export class LoginComponent implements OnInit { private static readonly MAX_REDIRECT_COUNT = 3; ngOnInit(): void { + this.authService.clearSessionOnLoginPage(); + this.route.queryParams.pipe(take(1)).subscribe(params => { if (params['reason'] === 'session_revoked') { this.infoMessage = this.translocoService.translate('auth.login.sessionRevoked'); diff --git a/booklore-ui/src/app/shared/service/auth.service.ts b/booklore-ui/src/app/shared/service/auth.service.ts index d13524db5..8de008081 100644 --- a/booklore-ui/src/app/shared/service/auth.service.ts +++ b/booklore-ui/src/app/shared/service/auth.service.ts @@ -77,10 +77,10 @@ export class AuthService { const refreshToken = this.getInternalRefreshToken(); this.http.post<{ logoutUrl: string | null }>(`${this.apiUrl}/logout`, {refreshToken}).subscribe({ next: (response) => { - this.clearSession(); if (response.logoutUrl) { window.location.href = response.logoutUrl; } else { + this.clearSession(); this.router.navigate(['/login']).then(() => window.location.reload()); } }, @@ -96,6 +96,10 @@ export class AuthService { this.router.navigate(['/login'], {queryParams: {reason}}); } + clearSessionOnLoginPage(): void { + this.clearSession(); + } + private clearSession(): void { localStorage.removeItem('accessToken_Internal'); localStorage.removeItem('refreshToken_Internal');