From 40bb16bbc982f041f47cf94a58eb9523b1eefb59 Mon Sep 17 00:00:00 2001 From: Ligbox Spec Hub Date: Sat, 20 Jun 2026 06:22:36 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20Agentic=20Ops=20UI=20auth=20=E2=80=94=20u?= =?UTF-8?q?se=20shared=20authHeaders/getToken.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes 401 not authenticated on roster/inbox when logged into Desk. Co-authored-by: Cursor --- projects/ops-desk/frontend/assets/agentic-ops.js | 12 +++++++----- projects/ops-desk/frontend/index.html | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/ops-desk/frontend/assets/agentic-ops.js b/projects/ops-desk/frontend/assets/agentic-ops.js index 2242db1..7b69dd6 100644 --- a/projects/ops-desk/frontend/assets/agentic-ops.js +++ b/projects/ops-desk/frontend/assets/agentic-ops.js @@ -3,11 +3,13 @@ let state = { threadId: null, selectedAgent: 'A6' }; async function api(path, opts = {}) { - const h = { ...(opts.headers || {}) }; - if (!(opts.body instanceof FormData)) h['Content-Type'] = 'application/json'; - const t = window.DeskAuth?.getToken?.(); - if (t) h.Authorization = `Bearer ${t}`; - const r = await fetch(`/api/v1/agents${path}`, { ...opts, headers: h }); + const h = authHeaders({ ...(opts.headers || {}) }); + if (!(opts.body instanceof FormData) && !h['Content-Type']) h['Content-Type'] = 'application/json'; + const r = await fetchWithTimeout(`/api/v1/agents${path}`, { ...opts, headers: h }); + if (r.status === 401) { + logout(); + throw new Error('sessão expirada — faça login novamente'); + } if (!r.ok) throw new Error(`${r.status} ${(await r.text()).slice(0, 200)}`); return r.json(); } diff --git a/projects/ops-desk/frontend/index.html b/projects/ops-desk/frontend/index.html index 7427ec0..8f3b44d 100644 --- a/projects/ops-desk/frontend/index.html +++ b/projects/ops-desk/frontend/index.html @@ -443,7 +443,7 @@ - +