这是登录方法:
public function login(){
$name = Input::get('name');
$password = Input::get("password");
$result = Auth::attempt(['name'=>$name,'password'=>$password]);
if($result){//$result是true
return redirect('admin/main');
}
return view('admin.login');
}
重定向到admin/main路由,然后经过Auth中间件验证
public function handle($request, Closure $next, $guard = null)
{
var_dump(Auth::check());//这个方法返回false
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
return $next($request);
}