当我登录时,我无法重定向到页面。在检查员网络中,页面显示但找到了302代码。
当我执行dd()时,auth :: attempt()和auth :: check()都返回true。
我的代码是:
Route::post('/login', function()
{
//echo "login...";
$username = Input::get('username');
$password = Input::get('password');
$remember = Input::get('remember');
$userdata = array(
'username' => Input::get('username'),
'password' => Input::get('password')
);
$rules = array(
'username' => 'required|exists:us,username',
'password' => 'required'
);
$validator = Validator::make($userdata, $rules);
if ($validator->passes())
{
//dd(Auth::attempt(['username' => $username, 'password' => $password], $remember));
if(Auth::attempt(['username' => $username, 'password' => $password], $remember))
{
//echo "ok";
//dd(Auth::check());
return Redirect::to('app/');
}
}
else
{
//echo "error";
return Redirect::to('login')->withErrors($validator);
}
});
答案 0 :(得分:0)
试试这个:
Route.php
Route::group(['middleware' => 'auth'], function() {
Route::get('app/groups', function() {
return view('app.main-folders');
});
});