Replies: 1 comment
-
if (! empty(auth()->user()) || ! empty(auth('api')->user())) { Did you try that? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using the
spatie/laravel-permissions
package and am having trouble using the team feature.I want to check if a user has certain permissions within a specific team (at route level [api.php]). However, I keep getting an unauthorized message because the team ID is not set in the route.
But: The team ID is set through middleware (which is called before the route and I can see the print statement being executed with proper id), but when I query the team ID in the route, it is null.
I would like to avoid validate the team ID/permission in the controller. Can anyone help me solve this issue?
The User has the role/permissions
My
api.php
(excerpt):My
RegionPermission.php
(called with middleware auth):Note that my $region_id is the corresponding Team ID
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions