This commit is contained in:
Lizandro Guarnizo
2026-04-16 23:07:53 -05:00
parent aa12a87fbb
commit 0164c51c1a
10 changed files with 236 additions and 41 deletions
+8 -1
View File
@@ -499,7 +499,8 @@ function authenticateUser($username, $password) {
// Cargar módulos del rol (slug y permiso)
$modules = [];
$modulePermissions = [];
$roleSlug = $admin['role'] ?? 'admin';
$roleSlug = $admin['role'] ?? 'admin';
$homePage = null;
if (!empty($admin['role_id'])) {
$modStmt = $pdo->prepare(
"SELECT module_slug, COALESCE(permission,'write') AS permission
@@ -510,6 +511,11 @@ function authenticateUser($username, $password) {
$modules[] = $row['module_slug'];
$modulePermissions[$row['module_slug']] = $row['permission'];
}
// Leer home_page del rol
$rpStmt = $pdo->prepare("SELECT home_page FROM roles WHERE id = ?");
$rpStmt->execute([$admin['role_id']]);
$rp = $rpStmt->fetch(PDO::FETCH_ASSOC);
$homePage = $rp['home_page'] ?? null;
} elseif ($roleSlug === 'admin') {
// Fallback: admin sin role_id tiene todos los módulos
$modules = array_keys(SYSTEM_MODULES);
@@ -524,6 +530,7 @@ function authenticateUser($username, $password) {
'email' => $admin['email'],
'role' => $roleSlug,
'role_id' => $admin['role_id'] ?? null,
'home_page' => $homePage,
'enfermera_id' => $admin['enfermera_id'] ?? null,
'modules' => $modules,
'module_permissions' => $modulePermissions,