From fa591873a95ed213835bfdd711e74e9622c6819f Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 28 Jul 2026 09:30:38 -0500 Subject: [PATCH] fix(auth): redirigir admins/supervisores al dashboard del turnero tras login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit login.php y index.php enviaban a v=recepcion a cualquier usuario con el módulo turnero que no fuera bacteriólogo, incluyendo superadmin, admin y supervisor. Esto causaba que al cerrar sesión y volver a entrar, el admin aterrizaba en recepción en vez del dashboard. Ahora: - bacteriologo → lugar_id=1 - superadmin/admin/supervisor → v=dashboard - recepcionista/otros → v=recepcion (comportamiento previo correcto) Co-Authored-By: Claude Sonnet 4.6 --- index.php | 9 ++++++++- login.php | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index 094062f..c65f38f 100644 --- a/index.php +++ b/index.php @@ -19,9 +19,16 @@ if (isEnfermero()) { } $_indexRole = $_SESSION['admin_user']['role'] ?? ''; $_indexModules = $_SESSION['admin_user']['modules'] ?? []; -if ($_indexRole === 'recepcionista' || (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true))) { +if ($_indexRole === 'recepcionista') { header('Location: erp.php?m=turnero&v=recepcion'); exit; } +if (in_array('turnero', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) { + $_indexAdminRoles = ['superadmin', 'admin', 'supervisor']; + $url = in_array($_indexRole, $_indexAdminRoles, true) + ? 'erp.php?m=turnero&v=dashboard' + : 'erp.php?m=turnero&v=recepcion'; + header('Location: ' . $url); exit; +} if (in_array('lab_dashboard', $_indexModules, true) && !in_array('whatsapp', $_indexModules, true)) { header('Location: lab_dashboard.php'); exit; } diff --git a/login.php b/login.php index d735a7b..f989691 100644 --- a/login.php +++ b/login.php @@ -106,6 +106,8 @@ if ($_POST && !$loginBlocked) { } elseif (in_array('turnero', $modules, true)) { if ($roleSlug === 'bacteriologo') { header('Location: erp.php?m=turnero&v=lugar&lugar_id=1'); + } elseif (in_array($roleSlug, ['superadmin', 'admin', 'supervisor'], true)) { + header('Location: erp.php?m=turnero&v=dashboard'); } else { header('Location: erp.php?m=turnero&v=recepcion'); }