Fix session invalidation for local auth bypass (#487)

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

View File

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

View File

@@ -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();
}
}