Hey all,
I am using the Spatie Laravel-Permissions package to configure roles and permissions on my app. I also use Auth0 to do external user authentication.
I am trying to setup a hasRole to verify the user has the correct role before accessing the index page, but, even though the user does have the correct role ('Admin'), the dd still comes back saying false. I've adjusted the default guard to be the Auth0 one, have also adjusted the user model to use the Auth0 guard as default too. But after all my troubleshooting I believe the issue is related to the $request and not matching up the data correctly.
Here's my controller:
public function index(Request $request)
{
dd($request->user()->hasRole('Admin','auth0'));
// nothing else here for now as I'll add it in after the dd comes back true.
}
I've also tried these dd variants to check further
dd($request->user()->role);
dd($request->auth()->user());
dd($request->auth()->user()->hasRole('Admin','auth0'));
dd($request->user()->hasPermissionTo('usermgmt.users'));
Where usermgmt.users is the route to view the index page (that requires the role of admin).
Not sure what to do next, any help would be appreciated, thanks!