From e393b891bd8e2bc4aeac21319ddc38660c8dec85 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 3 Aug 2016 23:02:42 +1000 Subject: [PATCH 1/2] improve error handling for document downloads --- app/Http/Controllers/DocumentAPIController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/DocumentAPIController.php b/app/Http/Controllers/DocumentAPIController.php index 01a05a17e2fa..5ceb477a5c7a 100644 --- a/app/Http/Controllers/DocumentAPIController.php +++ b/app/Http/Controllers/DocumentAPIController.php @@ -52,8 +52,10 @@ class DocumentAPIController extends BaseAPIController { $document = $request->entity(); - return DocumentController::getDownloadResponse($document); - } + if(array_key_exists($document->type, Document::$types)) + return DocumentController::getDownloadResponse($document); + else + return $this->errorResponse(['error'=>'Invalid mime type'],400); } /** * @param CreateDocumentRequest $request From ef8d2615f4b42e6deea83f06c38851695906ad5c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 3 Aug 2016 23:03:14 +1000 Subject: [PATCH 2/2] improve error handling for document downloads --- app/Http/Controllers/DocumentAPIController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/DocumentAPIController.php b/app/Http/Controllers/DocumentAPIController.php index 5ceb477a5c7a..3dd225d1445d 100644 --- a/app/Http/Controllers/DocumentAPIController.php +++ b/app/Http/Controllers/DocumentAPIController.php @@ -55,7 +55,8 @@ class DocumentAPIController extends BaseAPIController if(array_key_exists($document->type, Document::$types)) return DocumentController::getDownloadResponse($document); else - return $this->errorResponse(['error'=>'Invalid mime type'],400); } + return $this->errorResponse(['error'=>'Invalid mime type'],400); + } /** * @param CreateDocumentRequest $request