在我的HomeController
中,Auth::attempt()
函数运行良好,并且Auth::user()
数组值也成功打印。
如果问题是Auth
函数在我的ViewListController
中不起作用,但我在我的ViewListController
中指定了所需的类。
在我的HomeController.php
PostLogin
函数中:
if(Auth::attempt($request->only('email', 'password'))){
print_r(Auth::user());exit;
return redirect('inbox');
} else{
return redirect('login');
}
在我的ViewListController.php
GetListView
函数中:
if(Auth::check()){
echo "success";
}else{
echo "failed";
}
输出:失败。
知道我该如何解决这个问题吗?!
注释此行:
print_r(Auth::user());exit;
所以,基本上,替换这个...
if(Auth::attempt($request->only('email', 'password'))){
print_r(Auth::user());exit;
return redirect('inbox');
} else{
return redirect('login');
}
。有了这个:
if(Auth::attempt($request->only('email', 'password'))){
// print_r(Auth::user());exit;
return redirect('inbox');
} else{
return redirect('login');
}
该行看起来像某人放在那里但忘记删除的调试代码。
无论如何,每当调用脚本时,exit 总是终止脚本的执行。这意味着退出后的任何内容都会被完全忽略。请参阅官方文档。