Reputation: 1291
I am getting this error when I created my own middleware and used it
public function handle($request, Closure $next)
{
$privilege = $request->session()->has('privilege');
if($request->session()->has('privilege'))
{
if($privilege == "Owner" || $privilege == "owner")
{
return $next($request);
}
else
{
return redirect()->back()->withErrors(['privilege_check' => "You are not privileged to go there!."]);
}
}
return '/home';
}
Upvotes: 0
Views: 6010
Reputation: 1527
Check this
public function __construct()
{
$this->middleware(function ($request, $next) {
if(Session::get('user_id') == NULL)
{
return Redirect::to('login');
}else{
return $next($request);
}
});
}
Upvotes: 3
Reputation: 2817
Most probably you haven't set the session('privilege')
. If you have already set it up then close down the browser and run the application again from start. It maybe did not set up during the development.
Upvotes: 3