VC Public links pandora_enterprise#12329

This commit is contained in:
daniel 2023-11-07 09:20:48 +01:00
parent e516db1ef1
commit aaa590b65f
4 changed files with 32 additions and 32 deletions

View File

@ -183,7 +183,9 @@ if (isset($config['force_instant_logout']) === true
$_SESSION = [];
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
if (isset($_COOKIE[session_name()]) === true) {
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
}
if ($config['auth'] === 'saml' && empty($public_hash) === true) {
include_once $config['saml_path'].'simplesamlphp/lib/_autoload.php';

View File

@ -808,8 +808,8 @@ function loadVisualConsoleData(
getVisualConsoleItems: 1,
size: size,
visualConsoleId: vcId,
id_user: typeof id_user == undefined ? id_user : null,
auth_hash: typeof hash == undefined ? hash : null,
id_user: typeof id_user !== undefined ? id_user : null,
auth_hash: typeof hash !== undefined ? hash : null,
mode: mode,
widthScreen: widthScreen
},

View File

@ -1196,7 +1196,7 @@ class Item extends CachedModel
'operation/visual_console/view',
['id' => $vcId],
// No autologin from the public view.
!$config['public_view'],
!$config['public_access'],
$mobile_navigation,
[
'page' => 'visualmap',
@ -1302,7 +1302,7 @@ class Item extends CachedModel
'enterprise/operation/services/services',
['id_service' => $serviceId],
// No autologin from the public view.
!$config['public_view']
!$config['public_access']
);
} else {
// A regular module.
@ -1312,7 +1312,7 @@ class Item extends CachedModel
'operation/agentes/status_monitor',
['id_module' => $moduleId],
// No autologin from the public view.
!((isset($config['public_view']) === true) ? $config['public_view'] : false),
!((isset($config['public_access']) === true) ? $config['public_access'] : false),
$mobile_navigation,
[
'id' => $moduleId,
@ -1377,7 +1377,7 @@ class Item extends CachedModel
'operation/agentes/ver_agente',
['id_agente' => $agentId],
// No autologin from the public view.
!$config['public_view'],
!$config['public_access'],
$mobile_navigation,
[
'id' => $agentId,

View File

@ -33,7 +33,7 @@ require_once $config['homedir'].'/vendor/autoload.php';
ui_require_css_file('register', 'include/styles/', true);
// Connection lost alert.
ui_require_javascript_file('connection_check', 'include/javascript/', true);
// ui_require_javascript_file('connection_check', 'include/javascript/', true);
set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false));
$conn_title = __('Connection with console has been lost');
$conn_text = __('Connection to the console has been lost. Please check your internet connection.');
@ -47,7 +47,7 @@ global $vc_public_view;
global $config;
$vc_public_view = true;
$config['public_view'] = true;
$config['public_access'] = true;
// This starts the page head. In the call back function,
// things from $page['head'] array will be processed into the head.
@ -62,12 +62,6 @@ require_once 'include/functions_visual_map.php';
$hash = (string) get_parameter('hash');
// For public link issue.
$force_instant_logout = true;
if (isset($config['id_user']) === true) {
$force_instant_logout = false;
}
// Check input hash.
// DO NOT move it after of get parameter user id.
if (User::validatePublicHash($hash) !== true) {
@ -256,17 +250,17 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
if (menuLinks !== null) {
menuLinks.forEach(function (menuLink) {
menuLink.href = menuLink.href.replace(regex, replacement);
menuLink.href = menuLink.href.replace(
regex_hash,
replacement_hash
);
//menuLink.href = menuLink.href.replace(
// regex_hash,
// replacement_hash
//);
});
}
// Change the URL (if the browser has support).
if ("history" in window) {
var href = window.location.href.replace(regex, replacement);
href = href.replace(regex_hash, replacement_hash);
//href = href.replace(regex_hash, replacement_hash);
window.history.replaceState({}, document.title, href);
}
}
@ -321,20 +315,24 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
}
}
});
<?php if ($force_instant_logout === true) { ?>
// No click enabled when user not logged.
$( "a" ).on( "click", function( event ) {
event.preventDefault();
$('#visual-console-container').removeClass('is-updating');
$('.div-visual-console-spinner').remove();
});
<?php } ?>
</script>
<?php
if ($force_instant_logout === true) {
unset($userAccessMaintenance, $config['id_user'], $hash);
// Clean session to avoid direct access.
if ($config['force_instant_logout'] === true) {
// Force user logout.
$iduser = $_SESSION['id_usuario'];
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
$_SESSION = [];
session_destroy();
header_remove('Set-Cookie');
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
if (isset($_COOKIE[session_name()]) === true) {
setcookie(session_name(), $_COOKIE[session_name()], (time() - 4800), '/');
}
}
while (ob_get_length() > 0) {
ob_end_flush();
}