entrust icon indicating copy to clipboard operation
entrust copied to clipboard

Admin permission error - HttpException in Application.php line 900:

Open gidaban opened this issue 8 years ago • 9 comments

Hello guys

For now what i see, after auth roles and permissions working fine, but when type /admin/ i getting error normally i thing should be redirect to login form.

Route:

`Route::group(['prefix'=>'admin','middleware'=>['role:admin']],function(){

});`

and screen: error

Any ideas what is wrong?

gidaban avatar Mar 11 '17 15:03 gidaban

file "\zizaco\entrust\src\Entrust\Middleware\EntrustRole.php" public function handle($request, Closure $next, $roles) { if ($this->auth->guest() || !$request->user()->hasRole(explode("|", $roles))) { return redirect()->route("login"); } return $next($request); }

but what now with update ?

gidaban avatar Mar 13 '17 19:03 gidaban

Have a similar problem...

Feniksss avatar Apr 21 '17 14:04 Feniksss

Similar problem here...

josephmtinangi avatar Apr 26 '17 20:04 josephmtinangi

I have same problem, I think in this case in controller's __construct() method $this->middeware('permission:permissionNAME', ['only' => ['method_NAME', 'second_Method_NAME'] ] ) not working , same error found

in my case i user Another model Admin rather-than User so use Illuminate\Foundation\Auth\User as Authenticatable; class Admin extends Authenticatable { use Notifiable; use EntrustUserTrait;

 public function userRoles() {      
    return $this->hasMany('App\Models\RoleUser', 'user_id', 'id');
}

//#.... }

AmitVirpara avatar May 10 '17 05:05 AmitVirpara

edit file "\zizaco\entrust\src\Entrust\Middleware\EntrustRole.php" if ($this->auth->guest() || !$request->user()->hasRole(explode('|', $roles))) { //abort(403); change it return redirect()->route('login'); }

gidaban avatar May 17 '17 17:05 gidaban

edit file

"\zizaco\entrust\src\Entrust\Middleware\EntrustRole.php"

bad practice - changing a core of library.

Feniksss avatar May 24 '17 10:05 Feniksss

Sorry for digging, but how overwrite this method not in core library ?

gidaban avatar Jun 26 '18 18:06 gidaban

You could just copy this middleware to own app/http/middleware and change the code as needed and put the change class instead in kernel.php register of middleware removing this one. Should work. As I want the same behaviour. I am happy it should show the error code but would rather user redirect away to login rather than left on error page.

tristanbailey avatar Jul 12 '18 17:07 tristanbailey

It is missing a view for the error 403. You have to add a resources/views/errors/403.blade.php page, it will just call that page.

reqica7 avatar Mar 20 '20 15:03 reqica7