Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Fix skip-auth login 401 handling
rcourtman0e1cfd4574e2
diff --git a/frontend-modern/src/utils/__tests__/apiClient.org.test.ts b/frontend-modern/src/utils/__tests__/apiClient.org.test.tsindex 68b7f432f9..f7a5bacc8f 100644--- a/frontend-modern/src/utils/__tests__/apiClient.org.test.ts+++ b/frontend-modern/src/utils/__tests__/apiClient.org.test.ts@@ -17,6 +17,8 @@ describe('apiClient org context', () => {mockFetch.mockReset();global.fetch = mockFetch as unknown as typeof fetch;window.sessionStorage.clear();+ window.localStorage.clear();+ document.cookie = 'pulse_csrf=; Path=/; Max-Age=0';clearApiToken();setOrgID(null);});@@ -131,6 +133,26 @@ describe('apiClient org context', () => {expect(headers['X-Pulse-Org-ID']).toBe('default');});+ it('does not treat intentional unauthenticated 401 responses as expired sessions', async () => {+ document.cookie = 'pulse_csrf=csrf-token; Path=/';+ mockFetch.mockResolvedValue(+ new Response(JSON.stringify({ success: false, message: 'Invalid username or password' }), {+ status: 401,+ headers: { 'Content-Type': 'application/json' },+ }),+ );++ const response = await apiFetch('/api/login', {+ method: 'POST',+ skipAuth: true,+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ username: 'wrong', password: 'wrong' }),+ });++ expect(response.status).toBe(401);+ expect(window.localStorage.getItem('just_logged_out')).toBeNull();+ });+it('rejects malformed org IDs from storage and does not forward them to headers', async () => {mockFetch.mockResolvedValue(new Response('{}', { status: 200 }));window.sessionStorage.setItem('pulse_org_id', 'bad\norg');diff --git a/frontend-modern/src/utils/apiClient.ts b/frontend-modern/src/utils/apiClient.tsindex 9f000e6fdb..d992b86a72 100644--- a/frontend-modern/src/utils/apiClient.ts+++ b/frontend-modern/src/utils/apiClient.ts@@ -680,7 +680,7 @@ class ApiClient {'/api/charts/infrastructure',];const shouldSkipRedirect = skipRedirectUrls.some((path) => url.includes(path));- if (response.status === 401 && !shouldSkipRedirect) {+ if (response.status === 401 && !skipAuth && !shouldSkipRedirect) {logger.warn('Authentication expired - redirecting to login');// Clear auth and redirect to loginif (typeof window !== 'undefined') {