mercredi 1 août 2018

"User is not logged in"- Spatie Permissions Error

"message": "User is not logged in.", "exception": "Spatie\Permission\Exceptions\UnauthorizedException", "file": "/Users/robertjoseph/Dev/bengdi-api/vendor/spatie/laravel-permission/src/Exceptions/UnauthorizedException.php", "line": 45,

I get the above error anytime a user with the wrong roles access a route. I have been using the package for sometime now in normal projects but this time am building an API and i am getting this error is there something different that am missing out. I have added 'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class, 'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class, to my $routeMiddleware. After some googling i found out i should add 'permission' and 'role' to the $middlewareGroups under 'api'. but when i did i was would get the below error

"message": "Too few arguments to function Spatie\Permission\Middlewares\PermissionMiddleware::handle(), 2 passed in /Users/Jay/Dev/BDI-api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php on line 151 and exactly 3 expected", "exception": "Symfony\Component\Debug\Exception\FatalThrowableError", "file": "/Users/Jay/Dev/BDI-api/vendor/spatie/laravel-permission/src/Middlewares/PermissionMiddleware.php",



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire