From 5203c5550f1a28e70af7f439653b447b81606aaa Mon Sep 17 00:00:00 2001 From: mikeroq Date: Fri, 1 Jul 2022 08:25:01 -0500 Subject: [PATCH] Added a check for the require_accept_signature --- .../Account/AcceptanceController.php | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Account/AcceptanceController.php b/app/Http/Controllers/Account/AcceptanceController.php index e81a0329de4d..56b85933ba4d 100644 --- a/app/Http/Controllers/Account/AcceptanceController.php +++ b/app/Http/Controllers/Account/AcceptanceController.php @@ -12,6 +12,7 @@ use App\Models\CheckoutAcceptance; use App\Models\Company; use App\Models\Contracts\Acceptable; +use App\Models\Setting; use App\Models\User; use App\Models\AssetModel; use App\Models\Accessory; @@ -103,13 +104,6 @@ public function store(Request $request, $id) return redirect()->back()->with('error', trans('admin/users/message.error.accept_or_decline')); } - /** - * Get the signature and save it - */ - if (! Storage::exists('private_uploads/signatures')) { - Storage::makeDirectory('private_uploads/signatures', 775); - } - /** * Check for the eula-pdfs directory */ @@ -126,16 +120,30 @@ public function store(Request $request, $id) if ($request->input('asset_acceptance') == 'accepted') { - // The item was accepted, check for a signature - if ($request->filled('signature_output')) { - $sig_filename = 'siglog-'.Str::uuid().'-'.date('Y-m-d-his').'.png'; - $data_uri = $request->input('signature_output'); - $encoded_image = explode(',', $data_uri); - $decoded_image = base64_decode($encoded_image[1]); - Storage::put('private_uploads/signatures/'.$sig_filename, (string) $decoded_image); + // Check if signatures are enabled or not + if (Setting::getSettings()->require_accept_signature == '1') { + // Check if the signature directory exists, if not create it + if (! Storage::exists('private_uploads/signatures')) { + Storage::makeDirectory('private_uploads/signatures', 775); + } + + // The item was accepted, check for a signature + if ($request->filled('signature_output')) { + $sig_filename = 'siglog-'.Str::uuid().'-'.date('Y-m-d-his').'.png'; + $data_uri = $request->input('signature_output'); + $encoded_image = explode(',', $data_uri); + $decoded_image = base64_decode($encoded_image[1]); + Storage::put('private_uploads/signatures/'.$sig_filename, (string) $decoded_image); + + // No image data is present, kick them back. + // This mostly only applies to users on super-duper crapola browsers *cough* IE *cough* + } else { + return redirect()->back()->with('error', trans('general.shitty_browser')); + } } + // this is horrible switch($acceptance->checkoutable_type){ case 'App\Models\Asset':