Merge branch 'ent-9175-13829-visualizacion-de-contrasenas-en-texto-plano-dentro-del-inspector-onenet-pakistan' into 'develop'

Ent 9175 13829 visualizacion de contrasenas en texto plano dentro del inspector onenet pakistan

See merge request artica/pandorafms!5392
This commit is contained in:
Rafael Ameijeiras 2023-01-30 11:24:39 +00:00
commit 4984599132
4 changed files with 47 additions and 4 deletions

View File

@ -393,7 +393,7 @@ $data[1] = html_print_input_text(
$data[2] = __('Auth password').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
$data[3] = html_print_input_password(
'snmp3_auth_pass',
$snmp3_auth_pass,
'',
'',
15,
60,
@ -415,7 +415,7 @@ $data[1] = html_print_select(['DES' => __('DES'), 'AES' => __('AES')], 'snmp3_pr
$data[2] = __('Privacy pass').ui_print_help_tip(__('The pass length must be eight character minimum.'), true);
$data[3] = html_print_input_password(
'snmp3_privacy_pass',
$snmp3_privacy_pass,
'',
'',
15,
60,
@ -711,6 +711,12 @@ $(document).ready (function () {
$("#text-custom_ip_target").hide();
}
});
// Add input password values with js to hide it in browser inspector.
$('#password-snmp3_auth_pass').val('<?php echo $snmp3_auth_pass; ?>');
$('#password-snmp3_privacy_pass').val('<?php echo $snmp3_privacy_pass; ?>');
observerInputPassword();
});

View File

@ -85,6 +85,8 @@ $table_simple->rowstyle['macro_field'] = 'display:none';
push_table_simple($data, 'macro_field');
$password_fields = [];
// If there are $macros, we create the form fields
if (!empty($macros)) {
$macros = json_decode($macros, true);
@ -102,7 +104,8 @@ if (!empty($macros)) {
}
if ($m_hide) {
$data[1] = html_print_input_password($m['macro'], io_output_password($m['value']), '', 100, 1024, true);
$data[1] = html_print_input_password($m['macro'], '', '', 100, 1024, true);
array_push($password_fields, $m);
} else {
$data[1] = html_print_input_text(
$m['macro'],
@ -125,6 +128,17 @@ if (!empty($macros)) {
}
}
// Add input password values with js to hide it in browser inspector.
foreach ($password_fields as $k => $p) {
echo "
<script>
$(document).ready(() => {
$('input[name=\"".$p['macro']."\"]').val('".$p['value']."');
});
</script>
";
}
?>
<script type="text/javascript">
function changePluginSelect() {
@ -140,4 +154,8 @@ if (!empty($macros)) {
forced_title_callback();
}
$(document).ready(function () {
observerInputPassword();
});
</script>

View File

@ -116,7 +116,7 @@ $data[1] = html_print_input_text(
$data[2] = __('Password');
$data[3] = html_print_input_password(
'plugin_pass',
$plugin_pass,
'',
'',
15,
60,
@ -191,6 +191,11 @@ $(document).ready (function () {
$("#text-custom_ip_target").hide();
}
});
// Add input password values with js to hide it in browser inspector.
$('#password-plugin_pass').val('<?php echo $plugin_pass; ?>');
observerInputPassword();
});
</script>

View File

@ -1685,3 +1685,17 @@ function changePlugin() {
$("#selected_plugin_description_" + moduleProtocol).html(pluginDescription);
}
// Add observer to clear value when type attribute changes.
function observerInputPassword() {
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === "attributes" && mutation.attributeName === "type") {
mutation.target.value = "";
}
});
});
Array.from($("input[type=password]")).forEach(function(input) {
observer.observe(input, { attributes: true });
});
}