Reputation: 6629
Am using zizaco entruest rbac and these are my web routes causing error
Route::group(['prefix' => 'user-management', 'middleware' => ['permission:admin']], function() {
Route::get('/users', function(){
return "sds";
});
});
When i try navigating to
http://localhost:8000/user-management/users
am getting an error
Symfony \ Component \ HttpKernel \ Exception \ HttpException
No message
Where could i be wrong
I have commented all other routes and found this to be the culprit
I have setup my rbac as explained
https://github.com/Zizaco/entrust
Upvotes: 9
Views: 10411
Reputation: 394
apparently your code looks fine. I guess you are having some problem in your middleware its not allowing you to pass through. you have used permission:admin so i guess you should log in as admin and then it will be working fine.
Upvotes: 0
Reputation: 2436
You should create a 403.blade.php
template view under resources/views/errors
directory.
Your application's exception handler do not find the exception status code associated view, so it return the exception directly.
Upvotes: 8
Reputation: 4292
You need to put auth middleware
as well as it checks permission for an auth user within permission middleware
. You can fix it by just putting auth middleware
and then try logging in, now you can navigate to users
url.
Route::group(['prefix' => 'user-management', 'middleware' => ['auth', 'permission:admin']], function() {
Route::get('/users', function(){
return "sds";
});
});
Upvotes: 5
Reputation: 1186
I've looked up the middleware. It says the following:
if ($this->auth->guest() || !$request->user()->can($permissions)) {
abort(403);
}
This means that it crashes without a message if you aren't authenticated or you cannot do something because you don't have permission.
You could try to dd()
something in here before the abort. Just to see if it reaches this. If it does check this page in the Laravel documentation about abort()
and custom error pages: https://laravel.com/docs/5.5/errors#http-exceptions
Upvotes: 0
Reputation: 2919
To help you with this we need more information.
Not sure what kind of http code are you receiving (is it a 403? or a 500?).
Things you can do that might help:
Upvotes: 0