From b221d99e7ba922d22f1dca651cce7abc464cf9f3 Mon Sep 17 00:00:00 2001 From: MrM <11910225+mauro-miatello@users.noreply.github.com> Date: Sun, 31 Mar 2024 12:27:35 +0200 Subject: [PATCH 1/4] Encrypted values enhancement Show asterisks instead of the value, respecting the length of the field --- resources/views/hardware/view.blade.php | 31 ++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 461f2a4688..07f24ec3dd 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -415,19 +415,24 @@ @if ($field->isFieldDecryptable($asset->{$field->db_column_name()} )) @can('assets.view.encrypted_custom_fields') - ******** - - @if (($field->format=='URL') && ($asset->{$field->db_column_name()}!='')) - {{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }} - @elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!='')) - {{ \App\Helpers\Helper::gracefulDecrypt($field, \App\Helpers\Helper::getFormattedDateObject($asset->{$field->db_column_name()}, 'date', false)) }} - @else - {{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }} - @endif - - + @php + $fieldSize=strlen(Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()})) + @endphp + @if ($fieldSize>0) + {{ str_repeat('*', $fieldSize) }} + + @if (($field->format=='URL') && ($asset->{$field->db_column_name()}!='')) + {{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }} + @elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!='')) + {{ \App\Helpers\Helper::gracefulDecrypt($field, \App\Helpers\Helper::getFormattedDateObject($asset->{$field->db_column_name()}, 'date', false)) }} + @else + {{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }} + @endif + + + @endif @else {{ strtoupper(trans('admin/custom_fields/general.encrypted')) }} @endcan From 658ba092e2157f3f889b9e839836b20625045d62 Mon Sep 17 00:00:00 2001 From: MrM <11910225+mauro-miatello@users.noreply.github.com> Date: Sun, 31 Mar 2024 18:55:58 +0200 Subject: [PATCH 2/4] Hide encrypted values in hardware list Encrypted values are now hidden also in hardware list, clicking on them show the decrypted value --- resources/views/layouts/default.blade.php | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 216632ccf8..03442bd0b4 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -1041,6 +1041,64 @@ }); }); + // Select encrypted custom fields to hide them in the asset list + $(document).ready(function() { + // Selector for elements with css-padlock class + var selector = 'td.css-padlock'; + + // Function to add original value to elements + function addValue($element) { + // Get original value of the element + var originalValue = $element.text().trim(); + + // Show asterisks only for not empty values + if (originalValue !== '') { + // This is necessary to avoid loop because value is generated dynamically + if (originalValue !== '' && originalValue !== asterisks) $element.attr('value', originalValue); + + // Hide the original value and show asterisks of the same length + var asterisks = '*'.repeat(originalValue.length); + $element.text(asterisks); + + // Add click event to show original text + $element.click(function() { + var $this = $(this); + if ($this.text().trim() === asterisks) { + $this.text($this.attr('value')); + } else { + $this.text(asterisks); + } + }); + } + } + // Add value to existing elements + $(selector).each(function() { + addValue($(this)); + }); + + // Function to handle mutations in the DOM because content is generated dynamically + var observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + // Check if new nodes have been inserted + if (mutation.type === 'childList') { + mutation.addedNodes.forEach(function(node) { + if ($(node).is(selector)) { + addValue($(node)); + } else { + $(node).find(selector).each(function() { + addValue($(this)); + }); + } + }); + } + }); + }); + + // Configure the observer to observe changes in the DOM + var config = { childList: true, subtree: true }; + observer.observe(document.body, config); + }); + From a9ed748fb2be3ade683d235e6abd1ee4563ef83b Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 4 Apr 2024 11:39:49 -0700 Subject: [PATCH 3/4] adds audit dates to label options --- resources/views/partials/label2-field-definitions.blade.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/views/partials/label2-field-definitions.blade.php b/resources/views/partials/label2-field-definitions.blade.php index 8d8c680c94..b9c2ce3d55 100644 --- a/resources/views/partials/label2-field-definitions.blade.php +++ b/resources/views/partials/label2-field-definitions.blade.php @@ -313,6 +313,8 @@ + + From d548b800d5227f0a1fe30144212b70e9d3edd0f6 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 4 Apr 2024 15:43:33 -0700 Subject: [PATCH 4/4] nullifies location after ldap user sync --- app/Console/Commands/LdapSync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 05f60ee4e1..bd91c2bf25 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -390,7 +390,7 @@ class LdapSync extends Command $user->location_id = $location->id; } } - + $location = null; $user->ldap_import = 1; $errors = '';