From 7c1cc07ea9bafa96577f7648e544ba469d5be6f7 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Wed, 10 Apr 2024 16:44:54 +0200 Subject: [PATCH] #13035 fixed bug when add node with api --- .../include/class/JWTRepository.class.php | 27 +++++++++++-------- pandora_console/include/javascript/pandora.js | 6 ++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/class/JWTRepository.class.php b/pandora_console/include/class/JWTRepository.class.php index d99c218005..f5e9811b62 100644 --- a/pandora_console/include/class/JWTRepository.class.php +++ b/pandora_console/include/class/JWTRepository.class.php @@ -195,22 +195,27 @@ final class JWTRepository */ public static function syncSignatureWithNodes(?string $signature):void { - global $config; - if (function_exists('metaconsole_get_servers') === true) { - $sync = false; + if (function_exists('metaconsole_get_servers') === true + && function_exists('metaconsole_push_conf_to_node') === true + ) { + $sync_server = 0; $servers = metaconsole_get_servers(); foreach ($servers as $server) { - $config['JWT_signature'] = 1; - if (metaconsole_connect($server) == NOERR) { - config_update_value('JWT_signature', $signature, true); - $sync = true; - } + $ok_sync = metaconsole_push_conf_to_node( + $server, + [ 'JWT_signature' => $signature], + true + ); - $config['JWT_signature'] = 1; - metaconsole_restore_db(); + if ($ok_sync === true) { + $sync_server++; + } } - if ($sync === true) { + if (is_array($servers) === true + && count($servers) === $sync_server + && count($servers) > 0 + ) { config_update_value('JWT_signature', $signature, true); } } diff --git a/pandora_console/include/javascript/pandora.js b/pandora_console/include/javascript/pandora.js index 685fff6610..12fc17b75f 100644 --- a/pandora_console/include/javascript/pandora.js +++ b/pandora_console/include/javascript/pandora.js @@ -2748,7 +2748,10 @@ function redirectNode(url, target = "_blank") { get_jwt_for_login: 1 }, success: function(data) { - var $form = $(``); + const unique_id = "token_form_" + uniqId(); + var $form = $( + `` + ); $form.attr("method", "post"); $form.attr("action", url); if (data.success) { @@ -2761,6 +2764,7 @@ function redirectNode(url, target = "_blank") { $("body").append($form); $form.submit(); + $("#" + unique_id).remove(); } }); }