UncategorizedBackpackForLaravel

403 This action is unauthorized | BackpackForLaravel | Using Permission Manager of Spatie

By November 21, 2020 No Comments

I needed to customize the default user module that we get with the Permission Manager package. The author recommends extending the classes (\Backpack\PermissionManager\app\Http\Controllers\UserCrudController) instead of just mere copy-pasting it and unlinking it from the package code. I still copied the code from the vendor controller files (UserCrudController) and request files into the project’s app folder into their respective folders as a starting point and extended it to the code placed in the vendor directory by the package (\Backpack\PermissionManager\app\Http\Controllers\UserCrudController). The listing worked as expected however the update gave a 403.

Solution

So, my UserCrudController was extending

\Backpack\PermissionManager\app\Http\Controllers\UserCrudController

and the above file was extending CrudController

Not exactly sure why but I realized the $this->crud thing isn’t working as expected. So I removed all the code from my UserCrudController which was a duplicate from \Backpack\PermissionManager\app\Http\Controllers\UserCrudController such as the functions – setup, setupCreateOperation, setupUpdateOperation, except for my field customizations and it worked.

Doing this will also help us have a cleaner UserCrudController