Actualizar index.html
This commit is contained in:
16
index.html
16
index.html
@@ -341,9 +341,21 @@
|
|||||||
|
|
||||||
if (res.ok && json.ok) {
|
if (res.ok && json.ok) {
|
||||||
showToast("👋 ¡Hola de nuevo!");
|
showToast("👋 ¡Hola de nuevo!");
|
||||||
|
|
||||||
|
// Guardamos el token y los datos del usuario para usarlos en la app
|
||||||
localStorage.setItem('token', json.token);
|
localStorage.setItem('token', json.token);
|
||||||
// REDIRECCIÓN AL PANEL
|
localStorage.setItem('role', json.role);
|
||||||
setTimeout(() => { window.location.href = "panel.html"; }, 1000);
|
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 {
|
} else {
|
||||||
showToast("❌ " + (json.error || "Credenciales incorrectas"), true);
|
showToast("❌ " + (json.error || "Credenciales incorrectas"), true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user