Discussion

Permissions Modules Not Working

I'm creating a module hower after creating the permissions and make sure that they were check on Admin role, it keeps redirecting me to the dashboard.


Permission:

$group = PermissionFacade::add(
            'carousel',
            function (PermissionGroup $group) {
                $group->label('Banners');
            }
        );


        $group->addPermission(
            'carousel.index',
            function (Permission $permission) {
                $permission->label('carousel List')
                    ->routes('carousel.index');
            }
        );


Routes:

Route::middleware(['web', 'admin.auth'])
    ->prefix($baseAdminUrl)
    ->name('admin.')
    ->group(function () {
        Route::get('carousel', AvoRed\Banner\Http\Controllers\TableController::class)
            ->name('carousel.index');
    });
Pedro Martins
Pedro Martins
11 months ago

Found the solution when looking to the banners module on github, it seems it needs to have the 'permission' middleware to check the permissions, admin.auth isnt enough


Source:

https://github.com/avored/laravel-ecommerce/issues/422

Purvesh
Purvesh
11 months ago

Yes you are right. I have a custom middleware `permission` to check against the route.


Want to contribute?

© AvoRed 2021 Privacy