A free open source IT asset/license management system
Better error checking for private file display method
snipe8127484081bd
diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.phpindex 7ce992ce52..5aeb089523 100755--- a/app/Http/Controllers/AssetsController.php+++ b/app/Http/Controllers/AssetsController.php@@ -1012,7 +1012,11 @@ class AssetsController extends Controllerif (isset($asset->id)) {$this->authorize('view', $asset);- $log = Actionlog::find($fileId);+ if (!$log = Actionlog::find($fileId)) {+ return response('No matching record for that asset/file', 500)+ ->header('Content-Type', 'text/plain');++ }$file = $log->get_src('assets');@@ -1022,17 +1026,22 @@ class AssetsController extends Controller$filetype = Helper::checkUploadIsImage($file);+ if (!file_exists($file)) {+ return response('File '.$file.' not found on server', 404)+ ->header('Content-Type', 'text/plain');+ }+if ($filetype) {- $contents = file_get_contents($file);- return Response::make($contents)->header('Content-Type', $filetype);+ if ($contents = file_get_contents($file)) {+ return Response::make($contents)->header('Content-Type', $filetype);+ }+ return JsonResponse::create(["error" => "Failed validation: "], 500);}return Response::download($file);}- // Prepare the error message- $error = trans('admin/hardware/message.does_not_exist', compact('id'));// Redirect to the hardware management page- return redirect()->route('hardware.index')->with('error', $error);+ return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist', compact('id')));}/**