验证::尝试([ 'u_email'=> $凭据[ '电子邮件'], 'u_password'=> SHA1($凭据[ '密码']))
我'm use this code for authentication but i' m得到 Undefined index: password 错误可以帮助创建自定义身份验证控件而无需更改供应商库
Undefined index: password
提前谢谢你的帮助......
你需要做三件事 .
Auth::attempt(['u_email'=>$credentials['email'],'password' => $credentials['password']]);
密码为 password ,而不是 u_password 为 Auth::attempt() . 密钥不需要匹配密码列名称(为什么?参见第3点),但它必须等于 password - 例如,请参见第1点 .
在您的用户模型中实现 getAuthPassword() 方法,该方法将返回 u_password 列的值 . 用户提供程序使用此方法来获取密码哈希值,该哈希值稍后根据传递给 Auth::attempt() 的内容进行验证
//in your User.php public function getAuthPassword() { return $this->u_password; }
1 回答
你需要做三件事 .
密码为 password ,而不是 u_password 为 Auth::attempt() . 密钥不需要匹配密码列名称(为什么?参见第3点),但它必须等于 password - 例如,请参见第1点 .
在您的用户模型中实现 getAuthPassword() 方法,该方法将返回 u_password 列的值 . 用户提供程序使用此方法来获取密码哈希值,该哈希值稍后根据传递给 Auth::attempt() 的内容进行验证