Merge branch 'ent-12517-cambiar-nombre-al-token-allow-all-ips' into 'develop'

Ent 12517 Cambiar nombre al token "Allow all IPs"

See merge request artica/pandorafms!6696
This commit is contained in:
Rafael Ameijeiras 2023-11-28 09:58:44 +00:00
commit e5237aafe1
2 changed files with 62 additions and 43 deletions

View File

@ -672,8 +672,11 @@ if ($update_user) {
$values['email'] = (string) get_parameter('email');
$values['phone'] = (string) get_parameter('phone');
$values['comments'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('comments'))));
if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) {
$values['allowed_ip_active'] = ((int) get_parameter('allowed_ip_active', -1) === 0);
$values['allowed_ip_list'] = io_safe_input(strip_tags(io_safe_output((string) get_parameter('allowed_ip_list'))));
}
$values['is_admin'] = (get_parameter('is_admin', 0) === 0) ? 0 : 1;
$values['language'] = (string) get_parameter('language');
$values['timezone'] = (string) get_parameter('timezone');

View File

@ -859,10 +859,35 @@ $userManagementTable->data['fields_addSettings'][0] = html_print_textarea(
''
);
$userManagementTable->data['captions_addSettings'][1] = __('Login allowed IP list');
$userManagementTable->data['fields_addSettings'][1] = html_print_div(
if (users_is_admin($config['id_user']) === true || (bool) check_acl($config['id_user'], 0, 'PM') === true) {
$allowAllIpsContent = [];
$allowAllIpsContent[] = '<span>'.__('Enable IP allowlist').'</span>';
$allowAllIpsContent[] = html_print_div(
[
'class' => 'edit_user_allowed_ip',
'content' => html_print_checkbox_switch(
'allowed_ip_active',
0,
($user_info['allowed_ip_active'] ?? 0),
true,
false,
'handleIpAllowlist(this)'
),
],
true
);
$userManagementTable->data['captions_addSettings'][1] = html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $allowAllIpsContent),
],
true
);
$userManagementTable->data['fields_addSettings'][1] .= html_print_div(
[
'class' => 'edit_user_allowed_ip '.(((int) $user_info['allowed_ip_active'] === 1) ? '' : 'invisible'),
'content' => html_print_textarea(
'allowed_ip_list',
5,
@ -877,32 +902,13 @@ $userManagementTable->data['fields_addSettings'][1] = html_print_div(
$userManagementTable->data['fields_addSettings'][1] .= ui_print_input_placeholder(
__('Add the source IPs that will allow console access. Each IP must be separated only by comma. * allows all.'),
true
);
$allowAllIpsContent = [];
$allowAllIpsContent[] = '<span>'.__('Allow all IPs').'</span>';
$allowAllIpsContent[] = html_print_div(
true,
[
'content' => html_print_checkbox_switch(
'allowed_ip_active',
0,
($user_info['allowed_ip_active'] ?? 0),
true
),
],
true
'id' => 'info_allowed_ip',
'class' => ((int) $user_info['allowed_ip_active'] === 1) ? 'input_sub_placeholder' : 'input_sub_placeholder invisible',
]
);
$userManagementTable->data['fields_addSettings'][1] .= html_print_div(
[
'class' => 'margin-top-10',
'style' => 'display: flex; flex-direction: row-reverse; align-items: center;',
'content' => implode('', $allowAllIpsContent),
],
true
);
}
if ($config['ITSM_enabled'] && $config['ITSM_user_level_conf']) {
// Pandora ITSM user remote login.
@ -1040,4 +1046,14 @@ $(document).ready(function () {
}
})
});
function handleIpAllowlist(e){
if(e.checked === true) {
$('.edit_user_allowed_ip').show();
$('#info_allowed_ip').show();
} else {
$('.edit_user_allowed_ip').hide();
$('#info_allowed_ip').hide();
}
}
</script>