From 3292ca427520afbb07dd27217bc72d3d0c656d4c Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Thu, 1 Jan 2026 19:18:07 +0000 Subject: [PATCH] Fix auth token localStorage key consistency - Dashboard, viewer, and native viewer all now use guruconnect_token - Fixed loadMachines() to include Authorization header --- server/static/dashboard.html | 9 ++++++--- server/static/viewer.html | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/static/dashboard.html b/server/static/dashboard.html index 8942b30..f1a1f79 100644 --- a/server/static/dashboard.html +++ b/server/static/dashboard.html @@ -817,7 +817,10 @@ async function loadMachines() { try { - const response = await fetch("/api/sessions"); + const token = localStorage.getItem("guruconnect_token"); + const response = await fetch("/api/sessions", { + headers: { "Authorization": "Bearer " + token } + }); machines = await response.json(); // Update counts based on is_online status @@ -994,7 +997,7 @@ const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; const serverUrl = encodeURIComponent(protocol + "//" + window.location.host + "/ws/viewer"); - const token = localStorage.getItem("authToken"); + const token = localStorage.getItem("guruconnect_token"); const protocolUrl = `guruconnect://view/${connectSessionId}?server=${serverUrl}&token=${encodeURIComponent(token)}`; // Try to launch the protocol handler @@ -1152,7 +1155,7 @@ const protocol = window.location.protocol === "https:" ? "wss:" : "ws:"; const viewerName = user?.name || user?.email || "Technician"; - const token = localStorage.getItem("authToken"); + const token = localStorage.getItem("guruconnect_token"); const wsUrl = `${protocol}//${window.location.host}/ws/viewer?session_id=${sessionId}&viewer_name=${encodeURIComponent(viewerName)}&token=${encodeURIComponent(token)}`; console.log("Connecting chat to:", wsUrl); diff --git a/server/static/viewer.html b/server/static/viewer.html index 1383a6b..2279216 100644 --- a/server/static/viewer.html +++ b/server/static/viewer.html @@ -175,7 +175,7 @@ } // Get viewer name from localStorage (same as dashboard) - const user = JSON.parse(localStorage.getItem('user') || 'null'); + const user = JSON.parse(localStorage.getItem('guruconnect_user') || 'null'); const viewerName = user?.name || user?.email || 'Technician'; // State @@ -597,7 +597,7 @@ function connect() { const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const token = localStorage.getItem('authToken'); + const token = localStorage.getItem('guruconnect_token'); if (!token) { updateStatus('error', 'Not authenticated'); document.getElementById('overlay-text').textContent = 'Not logged in. Please log in first.';