diff --git a/code/frontend/src/app/core/auth/auth.service.ts b/code/frontend/src/app/core/auth/auth.service.ts index 1b5c1075..76a4292a 100644 --- a/code/frontend/src/app/core/auth/auth.service.ts +++ b/code/frontend/src/app/core/auth/auth.service.ts @@ -169,7 +169,6 @@ export class AuthService { const storedRefreshToken = localStorage.getItem('refresh_token'); if (!storedRefreshToken) { - this.clearAuth(); return of(null); } diff --git a/code/frontend/src/app/core/realtime/hub.service.ts b/code/frontend/src/app/core/realtime/hub.service.ts index be5b9ade..ee81b0f6 100644 --- a/code/frontend/src/app/core/realtime/hub.service.ts +++ b/code/frontend/src/app/core/realtime/hub.service.ts @@ -29,6 +29,10 @@ export abstract class HubService implements OnDestroy { this.connection = new signalR.HubConnectionBuilder() .withUrl(hubUrl, { accessTokenFactory: async () => { + // No tokens stored — trusted network bypass, no token needed + if (!this.authService.getAccessToken() && !localStorage.getItem('refresh_token')) { + return ''; + } if (this.authService.isTokenExpired(30)) { const result = await firstValueFrom(this.authService.refreshToken()); if (result) { @@ -72,7 +76,8 @@ export abstract class HubService implements OnDestroy { this.connected.set(true); this.reconnectAttempts = 0; this.onConnected(); - } catch { + } catch (err) { + console.warn('[SignalR] Connection failed:', err); this.scheduleReconnect(); } }