From 99afa76be2e3f58ffa737f3991e2a540fa2312df Mon Sep 17 00:00:00 2001 From: marsalva Date: Wed, 25 Feb 2026 08:33:28 +0000 Subject: [PATCH] Actualizar server.js --- server.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index f9b86b3..ac96718 100644 --- a/server.js +++ b/server.js @@ -1809,11 +1809,12 @@ app.post("/services/:id/location", authMiddleware, async (req, res) => { const locData = { lat, lng, updated_at: new Date().toISOString() }; + // CORRECCIÓN: Ahora usa owner_id para que funcione aunque el admin esté haciendo la prueba await pool.query(` UPDATE scraped_services SET raw_data = jsonb_set(COALESCE(raw_data, '{}'::jsonb), '{worker_location}', $1::jsonb) - WHERE id = $2 AND assigned_to = $3 - `, [JSON.stringify(locData), req.params.id, req.user.sub]); + WHERE id = $2 AND owner_id = $3 + `, [JSON.stringify(locData), req.params.id, req.user.accountId]); res.json({ ok: true }); } catch (e) { @@ -1825,12 +1826,9 @@ app.post("/services/:id/location", authMiddleware, async (req, res) => { app.get("/public/portal/:token/location/:serviceId", async (req, res) => { try { const { token, serviceId } = req.params; - - // Verificar dueño const clientQ = await pool.query("SELECT owner_id FROM clients WHERE portal_token = $1", [token]); if (clientQ.rowCount === 0) return res.status(404).json({ ok: false }); - // Cargar datos const serviceQ = await pool.query("SELECT raw_data FROM scraped_services WHERE id = $1 AND owner_id = $2", [serviceId, clientQ.rows[0].owner_id]); if (serviceQ.rowCount === 0) return res.status(404).json({ ok: false });