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 d7dc0e451e.

* Handles the update method, that also has the ability parameter as 'edit' instead of 'update'
This commit is contained in:
Ivan Nieto 2020-03-06 17:59:51 -06:00 committed by GitHub
parent 54fd8f81ff
commit 025ea93f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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