mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Fixed #6880 - correctly encrypt encrypted fields via the API
This commit is contained in:
parent
6728089106
commit
9eb7b668d1
|
@ -448,7 +448,13 @@ class AssetsController extends Controller
|
||||||
$model = AssetModel::find($request->get('model_id'));
|
$model = AssetModel::find($request->get('model_id'));
|
||||||
if ($model->fieldset) {
|
if ($model->fieldset) {
|
||||||
foreach ($model->fieldset->fields as $field) {
|
foreach ($model->fieldset->fields as $field) {
|
||||||
$asset->{$field->convertUnicodeDbSlug()} = e($request->input($field->convertUnicodeDbSlug(), null));
|
if ($field->field_encrypted=='1') {
|
||||||
|
if (Gate::allows('admin')) {
|
||||||
|
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt($request->input($field->convertUnicodeDbSlug()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$asset->{$field->convertUnicodeDbSlug()} = $request->input($field->convertUnicodeDbSlug());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,8 +503,12 @@ class AssetsController extends Controller
|
||||||
// Update custom fields
|
// Update custom fields
|
||||||
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
|
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
|
||||||
foreach ($model->fieldset->fields as $field) {
|
foreach ($model->fieldset->fields as $field) {
|
||||||
if ($request->has($field->convertUnicodeDbSlug())) {
|
if ($field->field_encrypted=='1') {
|
||||||
$asset->{$field->convertUnicodeDbSlug()} = e($request->input($field->convertUnicodeDbSlug()));
|
if (Gate::allows('admin')) {
|
||||||
|
$asset->{$field->convertUnicodeDbSlug()} = \Crypt::encrypt($request->input($field->convertUnicodeDbSlug()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$asset->{$field->convertUnicodeDbSlug()} = $request->input($field->convertUnicodeDbSlug());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue