entrust
entrust copied to clipboard
Admin permission error - HttpException in Application.php line 900:
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:

Any ideas what is wrong?
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 ?
Have a similar problem...
Similar problem here...
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');
}
//#.... }
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'); }
edit file
"\zizaco\entrust\src\Entrust\Middleware\EntrustRole.php"
bad practice - changing a core of library.
Sorry for digging, but how overwrite this method not in core library ?
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.
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.