From 025ea93f0527c271f38eb855b24222c1b88fcc9a Mon Sep 17 00:00:00 2001 From: Ivan Nieto Date: Fri, 6 Mar 2020 17:59:51 -0600 Subject: [PATCH] Fix for when a user with the correct permissions couldn't update Manufacturers. (#7882) * Changed the ability name from 'edit' to 'update'. Changed the order of execution: first checks if the manufacturer exists, then checks permissions * Handles the update method, that also has the ability parameter as edit instead of update" q * Revert "Handles the update method, that also has the ability parameter as edit instead of update"" This reverts commit d7dc0e451e69935325987a6ec6f8644854ab0e16. * Handles the update method, that also has the ability parameter as 'edit' instead of 'update' --- app/Http/Controllers/ManufacturersController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index fdcfe6903..c93aff906 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -96,11 +96,13 @@ class ManufacturersController extends Controller */ public function edit($id = null) { - $this->authorize('edit', Manufacturer::class); // Check if the manufacturer exists - if (is_null($item = Manufacturer::find($id))) { + if (!$item = Manufacturer::find($id)) { return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.does_not_exist')); } + //Handles manufacturer checks and permissions. + $this->authorize('update', Manufacturer::class); + // Show the page return view('manufacturers/edit', compact('item')); } @@ -118,7 +120,7 @@ class ManufacturersController extends Controller */ public function update(ImageUploadRequest $request, $manufacturerId = null) { - $this->authorize('edit', Manufacturer::class); + $this->authorize('update', Manufacturer::class); // Check if the manufacturer exists if (is_null($manufacturer = Manufacturer::find($manufacturerId))) { // Redirect to the manufacturer page