santigarcor / laratrust

Handle roles and permissions in your Laravel application
MIT License
2.19k stars 376 forks source link

Forbidden Admin panel - Middleware not working #509

Closed ajaybhargav closed 3 years ago

ajaybhargav commented 3 years ago

Describe the bug I have configured middleware option in laratrust panel as 'middleware' => ['role:admin'],

But I always get 403 forbidden error for user assigned as admin. I even tried a simpler middleware setup as 'auth', I am always redirected to login page, but since the user is already logged in i again get redirected to dashboard. I am not sure what is wrong. I tried almost everything clearing cache, views, config etc.

To Reproduce Steps to reproduce the behavior:

set middleware option in config/laratrust.php

panel->middleware->'role:admin'

ajaybhargav commented 3 years ago

any update on this?

ajaybhargav commented 3 years ago

Ok issue is resolved, if anyone else also facing the same issue; please make sure you need to add web + any other middleware you want to use with admin panel.

E.g. in my case it will be

'middleware' => ['web', 'role:admin'],

I think web should be a default for admin panel.