eHorus user level login conf added in user editor

This commit is contained in:
Luis Calvo 2019-05-28 13:14:42 +02:00
parent 3736d84589
commit 5966367f8f
9 changed files with 47 additions and 37 deletions

View File

@ -18,7 +18,7 @@ UPDATE `tnotification_source` SET `icon`="icono_logo_pandora.png" WHERE `descrip
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_acces` TINYINT(1) DEFAULT '1';
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1) DEFAULT '1';

View File

@ -1290,7 +1290,7 @@ ALTER TABLE `tusuario` DROP COLUMN `flash_chart`;
ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0';
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_acces` TINYINT(1);
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1);

View File

@ -69,8 +69,8 @@ $table_remote->style['name'] = 'font-weight: bold';
// Enable eHorus user configuration.
$row = [];
$row['name'] = ('Enable eHorus user configuration');
$row['control'] = html_print_checkbox_switch('ehorus_user_login', 1, $config['ehorus_user_login'], true);
$table_remote->data['ehorus_user_login'] = $row;
$row['control'] = html_print_checkbox_switch('ehorus_user_level_conf', 1, $config['ehorus_user_level_conf'], true);
$table_remote->data['ehorus_user_level_conf'] = $row;
// User.
$row = [];

View File

@ -155,6 +155,7 @@ if ($new_user && $config['admin_can_add_user']) {
if ($config['ehorus_user_level_conf']) {
$user_info['ehorus_user_level_user'] = '';
$user_info['ehorus_user_level_pass'] = '';
$user_info['ehorus_user_level_enabled'] = true;
}
}
@ -222,11 +223,17 @@ if ($create_user) {
// eHorus user level conf
if ($config['ehorus_user_level_conf']) {
$values['ehorus_user_acces'] = (bool) get_parameter('ehorus_user_acces', true);
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user', '');
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass', '');
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
if ($values['ehorus_user_level_enabled'] === true) {
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass');
} else {
$values['ehorus_user_level_user'] = null;
$values['ehorus_user_level_pass'] = null;
}
}
if ($id == '') {
ui_print_error_message(__('User ID cannot be empty'));
$user_info = $values;
@ -310,8 +317,18 @@ if ($update_user) {
$values['timezone'] = (string) get_parameter('timezone');
$values['default_event_filter'] = (int) get_parameter('default_event_filter');
$values['default_custom_view'] = (int) get_parameter('default_custom_view');
$values['ehorus_user_login_user'] = get_parameter('ehorus_user_login_user', $user_info['ehorus_user_login_user']);
$values['ehorus_user_login_pass'] = get_parameter(io_input_password((string) get_parameter('ehorus_user_login_pass', $user_info['ehorus_user_login_pass'])));
// eHorus user level conf
if ($config['ehorus_user_level_conf']) {
$values['ehorus_user_level_enabled'] = (bool) get_parameter('ehorus_user_level_enabled', false);
if ($values['ehorus_user_level_enabled'] === true) {
$values['ehorus_user_level_user'] = (string) get_parameter('ehorus_user_level_user');
$values['ehorus_user_level_pass'] = (string) get_parameter('ehorus_user_level_pass');
} else {
$values['ehorus_user_level_user'] = null;
$values['ehorus_user_level_pass'] = null;
}
}
$dashboard = get_parameter('dashboard', '');
$visual_console = get_parameter('visual_console', '');
@ -859,9 +876,9 @@ $table->data[16][1] = html_print_select($event_filter, 'default_event_filter', $
if ($config['ehorus_user_level_conf']) {
$table->data[17][0] = __('Ehorus configuration at user level');
$table->data[17][1] = html_print_checkbox('ehorus_user_acces', 1, $config['ehorus_user_level_conf'], true);
$table->data[17][1] = html_print_checkbox('ehorus_user_level_enabled', 1, $user_info['ehorus_user_level_enabled'], true);
$table->data[18][0] = __('eHorus user');
$table->data[19][0] = __('eHorys password');
$table->data[19][0] = __('eHorus password');
$table->data[18][1] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 15, 45, true);
$table->data[19][1] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 15, 45, true);
}
@ -958,10 +975,10 @@ $(document).ready (function () {
$('#checkbox-metaconsole_agents_manager').trigger('change');
show_data_section();
$('#checkbox-ehorus_user_acces').change(function () {
$('#checkbox-ehorus_user_level_enabled').change(function () {
switch_ehorus_conf();
});
$('#checkbox-ehorus_user_acces').trigger('change');
$('#checkbox-ehorus_user_level_enabled').trigger('change');
});
@ -1019,7 +1036,7 @@ function show_data_section () {
function switch_ehorus_conf()
{
if(!$('#checkbox-ehorus_user_acces').prop('checked'))
if(!$('#checkbox-ehorus_user_level_enabled').prop('checked'))
{
$("#user_configuration_table-18").hide();
$("#user_configuration_table-19").hide();

View File

@ -1353,7 +1353,7 @@ function config_update_config()
$error_update[] = __('Enable eHorus');
}
if (!config_update_value('ehorus_user_login', (int) get_parameter('ehorus_user_login', 0))) {
if (!config_update_value('ehorus_user_level_conf', (int) get_parameter('ehorus_user_level_conf', 0))) {
$error_update[] = __('eHorus user login');
}

View File

@ -59,9 +59,9 @@ $curl_timeout = $config['ehorus_req_timeout'];
$base_url = 'https://'.$hostname.':'.$port;
// If user login is enabled, fetch user and pass from user info
if ($config['ehorus_user_login']) {
$user = $user_info['ehorus_user_login_user'];
$password = io_safe_output(io_output_password($user_info['ehorus_user_login_pass']));
if ($config['ehorus_user_level_conf']) {
$user = $user_info['ehorus_user_level_user'];
$password = io_safe_output(io_output_password($user_info['ehorus_user_level_pass']));
}
// Get the login auth token

View File

@ -1267,7 +1267,7 @@ if ($config['ehorus_enabled'] && !empty($config['ehorus_custom_field'])
) || is_user_admin($config['id_user']))
) {
$user_info = users_get_user_by_id($config['id_user']);
if ($config['ehorus_user_login'] && !$user_info['ehorus_user_login_user'] && !$user_info['ehorus_user_login_pass']) {
if ($config['ehorus_user_level_conf'] && !$user_info['ehorus_user_level_user'] && !$user_info['ehorus_user_level_pass']) {
// If ehorus user configuration is enabled, and no password provided, do nothing.
} else {
$ehorus_agent_id = agents_get_agent_custom_field($id_agente, $config['ehorus_custom_field']);

View File

@ -123,8 +123,8 @@ if (isset($_GET['modified']) && !$view_mode) {
}
$upd_info['time_autorefresh'] = (int) get_parameter('time_autorefresh', 0);
$upd_info['ehorus_user_login_user'] = get_parameter('ehorus_user_login_user', $user_info['ehorus_user_login_user']);
$upd_info['ehorus_user_login_pass'] = get_parameter('ehorus_user_login_pass', $user_info['ehorus_user_login_pass']);
$upd_info['ehorus_user_level_user'] = get_parameter('ehorus_user_level_user');
$upd_info['ehorus_user_level_pass'] = get_parameter('ehorus_user_level_pass');
$is_admin = db_get_value('is_admin', 'tusuario', 'id_user', $id);
@ -645,7 +645,7 @@ if (!is_metaconsole()) {
</div>
</div>';
if ($config['ehorus_enabled'] && $config['ehorus_user_login']) {
if ($config['ehorus_enabled'] && $config['ehorus_user_level_conf']) {
// eHorus user remote login
$table_remote = new StdClass();
$table_remote->data = [];
@ -659,19 +659,19 @@ if ($config['ehorus_enabled'] && $config['ehorus_user_login']) {
// Title
$row = [];
$row['control'] = '<p class="edit_user_labels">'.__('eHorus user configuration').': </p>';
$table_remote->data['ehorus_user_login'] = $row;
$table_remote->data['ehorus_user_level_conf'] = $row;
// User.
$row = [];
$row['name'] = __('User');
$row['control'] = html_print_input_text('ehorus_user_login_user', $user_info['ehorus_user_login_user'], '', 30, 100, true);
$table_remote->data['ehorus_user_login_user'] = $row;
$row['control'] = html_print_input_text('ehorus_user_level_user', $user_info['ehorus_user_level_user'], '', 30, 100, true);
$table_remote->data['ehorus_user_level_user'] = $row;
// Pass.
$row = [];
$row['name'] = __('Password');
$row['control'] = html_print_input_password('ehorus_user_login_pass', io_output_password($user_info['ehorus_user_login_pass']), '', 30, 100, true);
$table_remote->data['ehorus_user_login_pass'] = $row;
$row['control'] = html_print_input_password('ehorus_user_level_pass', io_output_password($user_info['ehorus_user_level_pass']), '', 30, 100, true);
$table_remote->data['ehorus_user_level_pass'] = $row;
// Test.
$ehorus_port = db_get_value('value', 'tconfig', 'token', 'ehorus_port');
@ -808,13 +808,6 @@ if (!defined('METACONSOLE')) {
// Closes no meta condition.
}
function ehorus_user_login_conf()
{
}
?>
<script language="javascript" type="text/javascript">
@ -1141,8 +1134,8 @@ function show_double_auth_deactivation () {
}
function ehorus_connection_test(host, port) {
var user = $('input#text-ehorus_user_login_user').val();
var pass = $('input#password-ehorus_user_login_pass').val();
var user = $('input#text-ehorus_user_level_user').val();
var pass = $('input#password-ehorus_user_level_pass').val();
debugger;
var badRequestMessage = '<?php echo __('Empty user or password'); ?>';

View File

@ -1148,7 +1148,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` (
`default_custom_view` int(10) unsigned NULL default '0',
`ehorus_user_level_user` VARCHAR(60),
`ehorus_user_level_pass` VARCHAR(45),
`ehorus_user_acces` TINYINT(1),
`ehorus_user_level_enabled` TINYINT(1),
CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL,
UNIQUE KEY `id_user` (`id_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;