From d15a25a35974047949ca80124345042e648418f6 Mon Sep 17 00:00:00 2001 From: marsalva Date: Sun, 22 Feb 2026 14:26:46 +0000 Subject: [PATCH] Actualizar index.html --- index.html | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index fcd68bd..24a2348 100644 --- a/index.html +++ b/index.html @@ -339,11 +339,23 @@ }); const json = await res.json(); - if (res.ok && json.ok) { + if (res.ok && json.ok) { showToast("👋 ¡Hola de nuevo!"); + + // Guardamos el token y los datos del usuario para usarlos en la app localStorage.setItem('token', json.token); - // REDIRECCIÓN AL PANEL - setTimeout(() => { window.location.href = "panel.html"; }, 1000); + localStorage.setItem('role', json.role); + localStorage.setItem('userName', json.name); + + // REDIRECCIÓN INTELIGENTE SEGÚN EL ROL + setTimeout(() => { + if (json.role === 'operario') { + window.location.href = "operario.html"; + } else { + window.location.href = "panel.html"; + } + }, 1000); + } else { showToast("❌ " + (json.error || "Credenciales incorrectas"), true); }