From 9e437e8a12b094ecaa12ddb2f197983d1688e073 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 24 Jul 2017 16:53:35 +0300 Subject: [PATCH] Improve error when downloading deleted invoice --- app/Http/Controllers/ClientPortalController.php | 4 ++++ app/Http/Controllers/InvoiceApiController.php | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index ee9f284943b1..7b25e02918be 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -584,6 +584,10 @@ class ClientPortalController extends BaseController private function returnError($error = false) { + if (request()->phantomjs) { + abort(404); + } + return response()->view('error', [ 'error' => $error ?: trans('texts.invoice_not_found'), 'hideHeader' => true, diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 7eeb44e1ebd7..a6f700ef0f84 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -423,7 +423,12 @@ class InvoiceApiController extends BaseAPIController public function download(InvoiceRequest $request) { $invoice = $request->entity(); + $pdfString = $invoice->getPDFString(); - return $this->fileReponse($invoice->getFileName(), $invoice->getPDFString()); + if ($pdfString) { + return $this->fileReponse($invoice->getFileName(), $pdfString); + } else { + abort(404); + } } }