Fix session invalidation for local auth bypass (#487)

This commit is contained in:
Flaminel authored and GitHub committed 2026-03-02 13:34:20 +02:00
1 parent bdb956ec84
commit 63931763c4
2 files changed
+6 -2

No files matched your search

@@ -169,7 +169,6 @@ export class AuthService {
const storedRefreshToken = localStorage.getItem('refresh_token');
if (!storedRefreshToken) {
this.clearAuth();
return of(null);
}
@@ -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();
}
}