Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Laravel's routing error with HttpException?

Tags:

php

laravel

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
like image 604
Geoff Avatar asked Sep 21 '17 18:09

Geoff


2 Answers

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";
    });

 });
like image 127
Basheer Kharoti Avatar answered Sep 17 '22 09:09

Basheer Kharoti


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.

like image 31
Cong Chen Avatar answered Sep 21 '22 09:09

Cong Chen