From 2ad7c609d9a8a35feb2b9ee2a10b7b412de5d1ae Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 15 Feb 2017 22:59:23 +0200 Subject: [PATCH] Add support for phantomjs secret --- app/Http/Middleware/Authenticate.php | 4 ++++ app/Models/Invoice.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index de82df62aea2..0aa3d1187520 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -77,6 +77,10 @@ class Authenticate if (!$authenticated && $contact && !$contact->password) { $authenticated = true; } + + if (env('PHANTOMJS_SECRET') && $request->phantomjs_secret && hash_equals(env('PHANTOMJS_SECRET'), $request->phantomjs_secret)) { + $authenticated = true; + } } if (!$authenticated) { diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index bc39e95d4cf3..49438dc81ea3 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -1203,7 +1203,7 @@ class Invoice extends EntityModel implements BalanceAffecting try { if (env('PHANTOMJS_BIN_PATH')) { - $pdfString = CurlUtils::phantom('GET', $link . '?phantomjs=true'); + $pdfString = CurlUtils::phantom('GET', $link . '?phantomjs=true&phantomjs_secret=' . env('PHANTOMJS_SECRET')); } elseif ($key = env('PHANTOMJS_CLOUD_KEY')) { if (Utils::isNinjaDev()) { $link = env('TEST_LINK');