登录会话验证
public function store(Request $request)
{
$credentials = $this->validate($request, [
'email' => 'required|email|max:255',
'password' => 'required'
]);
if (Auth::attempt($credentials)) {
// 登录成功后的相关操作
} else {
// 登录失败后的相关操作
}
return;
}
教程例子中验证完登录字段有效性之后,又进行账号密码比对Auth::attempt($credentials),我这里测试的$credentials,如果字段有效,返回的是一个null,再传到attempt中与数据库进行比对,等于传入了一个空值,例子真的没有问题吗?我这里在本地测试的报错如下:
Argument 1 passed to Illuminate\Auth\SessionGuard::attempt() must be of the type array, null given, called in E:\xampp\htdocs\weibo.im\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 294 and defined
推荐文章: