From b011b746c0a643cf5adb6d18a6c2c5baabd42083 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 24 Apr 2024 09:49:03 +0200 Subject: [PATCH] #13591 public dashboard and visual console permisions user not logged --- .../include/lib/Dashboard/Manager.php | 27 +++++++++++++++++++ pandora_console/include/lib/User.php | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/lib/Dashboard/Manager.php b/pandora_console/include/lib/Dashboard/Manager.php index 36769c4338..e55cdd5d1e 100644 --- a/pandora_console/include/lib/Dashboard/Manager.php +++ b/pandora_console/include/lib/Dashboard/Manager.php @@ -411,6 +411,33 @@ class Manager implements PublicLogin $config['public_dashboard'] = true; $config['force_instant_logout'] = true; return true; + } else { + $dashboards = self::getDashboards(); + $dashboards = array_reduce( + $dashboards, + function ($carry, $item) { + $carry[$item['id']] = $item['name']; + return $carry; + }, + [] + ); + + foreach ($dashboards as $key => $layout) { + $hash_compare = self::generatePublicHash($key); + if (hash_equals($hash, $hash_compare)) { + // "Log" user in. + if (session_status() !== PHP_SESSION_ACTIVE) { + session_start(); + } + + $_SESSION['id_usuario'] = get_parameter('id_user'); + session_write_close(); + + $config['public_dashboard'] = true; + $config['force_instant_logout'] = true; + return true; + } + } } // Remove id user from config array if authentication has failed. diff --git a/pandora_console/include/lib/User.php b/pandora_console/include/lib/User.php index d11c92e22a..5baace3b12 100644 --- a/pandora_console/include/lib/User.php +++ b/pandora_console/include/lib/User.php @@ -230,7 +230,7 @@ class User extends Entity implements PublicLogin global $config; $str = $config['dbpass']; - $str .= $config['id_user']; + $str .= ($config['id_user'] ?? get_parameter('id_user')); $str .= $other_secret; return hash('sha256', $str); }