mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Decrypt encrypted fields
This commit is contained in:
parent
20376daec4
commit
635299cd74
|
@ -79,6 +79,37 @@ class AssetsTransformer
|
|||
'user_can_checkout' => (bool) $asset->availableForCheckout(),
|
||||
];
|
||||
|
||||
|
||||
if ($asset->model->fieldset) {
|
||||
$fields_array = array();
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
|
||||
if ($field->isFieldDecryptable($asset->{$field->convertUnicodeDbSlug()})) {
|
||||
$decrypted = \App\Helpers\Helper::gracefulDecrypt($field,$asset->{$field->convertUnicodeDbSlug()});
|
||||
$value = (Gate::allows('superadmin')) ? $decrypted : strtoupper(trans('admin/custom_fields/general.encrypted'));
|
||||
|
||||
$fields_array = [$field->convertUnicodeDbSlug() => $value];
|
||||
|
||||
|
||||
// $fields_array[$field->name] = [
|
||||
// 'field' => $field->convertUnicodeDbSlug(),
|
||||
// 'value' => $value
|
||||
// ];
|
||||
|
||||
} else {
|
||||
// $fields_array[$field->name] = [
|
||||
// 'field' => $field->convertUnicodeDbSlug(),
|
||||
// 'value' => $asset->{$field->convertUnicodeDbSlug()}
|
||||
// ];
|
||||
$fields_array = [$field->convertUnicodeDbSlug() => $asset->{$field->convertUnicodeDbSlug()}];
|
||||
|
||||
|
||||
}
|
||||
$array += $fields_array;
|
||||
//$array['custom_fields'] = $fields_array;
|
||||
}
|
||||
}
|
||||
|
||||
$permissions_array['available_actions'] = [
|
||||
'checkout' => (bool) Gate::allows('checkout', Asset::class),
|
||||
'checkin' => (bool) Gate::allows('checkin', Asset::class),
|
||||
|
@ -88,14 +119,6 @@ class AssetsTransformer
|
|||
];
|
||||
|
||||
$array += $permissions_array;
|
||||
|
||||
if ($asset->model->fieldset) {
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
$fields_array = [$field->name => $asset->{$field->convertUnicodeDbSlug()}];
|
||||
$array += $fields_array;
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue