spatie/laravel-permission

Problem with denied access using the middleware aliases role, permission, and role_or_permission in Spatie Permission version 6 and higher.

Zebedeu opened this issue · 1 comments

I am facing an issue with the middleware aliases 'role', 'permission', and 'role_or_permission' in Spatie Permission version 6 and higher. I am using Laravel 10 along with the stancl/tenancy package. The problem is that even when the user does not have the necessary permissions, access continues to be allowed instead of being denied.

Steps to reproduce the issue:

  1. I installed Spatie Permission version 6.0 or higher and the stancl/tenancy package in my Laravel 10 project.
  2. I correctly configured Spatie Permission and created the necessary permissions and roles.
  3. I used the middleware aliases 'role', 'permission', and 'role_or_permission' in my routes to restrict access based on permissions and roles.
  4. Even when the user does not have the necessary permissions or roles, access is being allowed instead of being denied.

Expected:
I expected that when using the middleware aliases 'role', 'permission', and 'role_or_permission', access would be correctly denied when the user does not have the necessary permissions or roles.

Current:
Currently, even when the user does not have the necessary permissions or roles, access is being allowed instead of being denied.

It's been a long time since I used the stancl/tenancy package. From what I recall this package works fine with it. So it's likely something else in your application that is overriding this package.

Please provide a minimal demo application, including the stancl/tenancy package and sufficient seeder, which replicates this problem so we can investigate further.