diff --git a/frontend/src/app/service/auth.service.ts b/frontend/src/app/service/auth.service.ts index 158ea5f..dfc3212 100644 --- a/frontend/src/app/service/auth.service.ts +++ b/frontend/src/app/service/auth.service.ts @@ -206,18 +206,29 @@ export class AuthService { try { console.log('Logging out'); this.user = null; - this.oauthService.logOut(); - // Clear any lingering token in storage + + // Prevent redirect to Authentik by doing a local logout only + // Instead of using oauthService.logOut() which redirects to the provider + + // Clear tokens from storage + this.oauthService.logOut(false); // logOut(false) prevents redirect + + // Clear any lingering tokens manually localStorage.removeItem('access_token'); + localStorage.removeItem('id_token'); + localStorage.removeItem('refresh_token'); sessionStorage.removeItem('access_token'); + sessionStorage.removeItem('id_token'); + sessionStorage.removeItem('refresh_token'); + + // Navigate to landing page this.router.navigate(['/']); } catch (err) { console.error('Exception in logout:', err); - // Force clear tokens - this.oauthService.revokeTokenAndLogout().catch(() => { - // Just navigate to home page as fallback - this.router.navigate(['/']); - }); + // Force clear tokens locally + localStorage.clear(); // Clear all local storage as a last resort + sessionStorage.clear(); + this.router.navigate(['/']); } }