diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 37e749597..65a13edb2 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -6,6 +6,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use App\Helpers\Helper; use Illuminate\Validation\ValidationException; use Illuminate\Auth\AuthenticationException; +use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException; use Log; use Throwable; use JsonException; @@ -28,6 +29,7 @@ class Handler extends ExceptionHandler \Intervention\Image\Exception\NotSupportedException::class, \League\OAuth2\Server\Exception\OAuthServerException::class, JsonException::class, + SCIMException::class, //these generally don't need to be reported ]; /** @@ -53,7 +55,7 @@ class Handler extends ExceptionHandler * * @param \Illuminate\Http\Request $request * @param \Exception $e - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response */ public function render($request, Throwable $e) { @@ -70,6 +72,9 @@ class Handler extends ExceptionHandler return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid JSON'), 422); } + if ($e instanceof SCIMException) { + return response()->json(Helper::formatStandardApiResponse('error', null, 'invalid SCIM Request'), 400); + } // Handle Ajax requests that fail because the model doesn't exist if ($request->ajax() || $request->wantsJson()) { @@ -113,8 +118,8 @@ class Handler extends ExceptionHandler * * @param \Illuminate\Http\Request $request * @param \Illuminate\Auth\AuthenticationException $exception - * @return \Illuminate\Http\Response - */ + * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse + */ protected function unauthenticated($request, AuthenticationException $exception) { if ($request->expectsJson()) { diff --git a/app/Http/Controllers/Api/ImportController.php b/app/Http/Controllers/Api/ImportController.php index 2426a49be..6f5fc05ff 100644 --- a/app/Http/Controllers/Api/ImportController.php +++ b/app/Http/Controllers/Api/ImportController.php @@ -126,7 +126,14 @@ class ImportController extends Controller } $file_name = date('Y-m-d-his').'-'.$fixed_filename; $import->file_path = $file_name; + $import->filesize = null; + + if (!file_exists($path.'/'.$file_name)) { + return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found')), 500); + } + $import->filesize = filesize($path.'/'.$file_name); + $import->save(); $results[] = $import; } diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.php index d0f7fea60..a0438ef07 100644 --- a/app/Http/Controllers/Api/SettingsController.php +++ b/app/Http/Controllers/Api/SettingsController.php @@ -271,7 +271,7 @@ class SettingsController extends Controller $headers = ['ContentType' => 'application/zip']; return Storage::download($path.'/'.$file, $file, $headers); } else { - return response()->json(Helper::formatStandardApiResponse('error', null, 'File not found')); + return response()->json(Helper::formatStandardApiResponse('error', null, trans('general.file_not_found'))); } } diff --git a/config/logging.php b/config/logging.php index 94495a2a3..65b717750 100644 --- a/config/logging.php +++ b/config/logging.php @@ -117,6 +117,11 @@ $config = [ \Log::info("IGNORING E_WARNING in production mode: ".$args->getMessage()); return true; // "TRUE - you should ignore it!" } + $needle = "ArieTimmerman\\Laravel\\SCIMServer\\Exceptions\\SCIMException"; + if (App::environment('production') && is_string($args) && strncmp($args, $needle, strlen($needle) ) === 0 ) { + \Log::info("String: '$args' looks like a SCIM Exception; ignoring error"); + return true; //yes, *do* ignore it + } return false; }, ], diff --git a/database/factories/ActionlogFactory.php b/database/factories/ActionlogFactory.php index 33cc83ead..382a6412c 100644 --- a/database/factories/ActionlogFactory.php +++ b/database/factories/ActionlogFactory.php @@ -55,7 +55,7 @@ class ActionlogFactory extends Factory [ 'assigned_to' => $target->id, 'assigned_type' => \App\Models\User::class, - 'assigned_to' => $target->location_id, + 'location_id' => $target->location_id, ] ); @@ -84,7 +84,7 @@ class ActionlogFactory extends Factory [ 'assigned_to' => $target->id, 'assigned_type' => \App\Models\Location::class, - 'assigned_to' => $target->id, + 'location_id' => $target->id, ] ); diff --git a/resources/lang/de/general.php b/resources/lang/de/general.php index 08412e2e2..3f9634b60 100644 --- a/resources/lang/de/general.php +++ b/resources/lang/de/general.php @@ -395,7 +395,7 @@ return [ 'end_date' => 'Enddatum', 'alt_uploaded_image_thumbnail' => 'Hochgeladene Miniaturansicht', 'placeholder_kit' => 'Kit auswählen', - 'file_not_found' => 'File not found', + 'file_not_found' => 'File not found on server', 'preview_not_available' => '(no preview)', 'setup' => 'Setup', 'pre_flight' => 'Pre-Flight',