Hash::check() 总是 returns 错误
Hash::check() always returns false
我正在尝试检查登录时用户输入的密码和数据库中的散列密码,但它总是 returns 错误。
这是控制器中散列密码的代码
$doctor = new doctor;
$doctor->name = $request->name;
$doctor->address = $request->address;
$doctor->email = $request->email;
$doctor->mobile = $request->mobile;
$password = Hash::make($request->doctorPassword);
$doctor->doctorPassword = $password;
这是验证密码的代码:
$data = $request->all();
$user = doctor::where('email',$data['doctorUsername'])->first();
if ($user) {
if (Hash::check($user->doctorPassword, $data['doctorPassword']))
{
return view($this->filePath . '.doctorProfile');
}
}
总是returns错误。
您的参数顺序不正确。您应该先添加密码 的纯文本版本,如下所示:
Hash::check($data['doctorPassword'], $user->doctorPassword);
我觉得这里一切都还好。只需将 hashedPassword $user->doctorPassword
作为 Hash::check() 中的第二个参数。干杯 :D
$user = doctor::where('email',$data['doctorUsername'])->first();
if ($user) {
if (Hash::check($data['doctorPassword'], $user->doctorPassword))
{
return view($this->filePath . '.doctorProfile');
}
请检查此 link:https://laravel.com/docs/5.8/hashing
我正在尝试检查登录时用户输入的密码和数据库中的散列密码,但它总是 returns 错误。
这是控制器中散列密码的代码
$doctor = new doctor;
$doctor->name = $request->name;
$doctor->address = $request->address;
$doctor->email = $request->email;
$doctor->mobile = $request->mobile;
$password = Hash::make($request->doctorPassword);
$doctor->doctorPassword = $password;
这是验证密码的代码: $data = $request->all();
$user = doctor::where('email',$data['doctorUsername'])->first();
if ($user) {
if (Hash::check($user->doctorPassword, $data['doctorPassword']))
{
return view($this->filePath . '.doctorProfile');
}
}
总是returns错误。
您的参数顺序不正确。您应该先添加密码 的纯文本版本,如下所示:
Hash::check($data['doctorPassword'], $user->doctorPassword);
我觉得这里一切都还好。只需将 hashedPassword $user->doctorPassword
作为 Hash::check() 中的第二个参数。干杯 :D
$user = doctor::where('email',$data['doctorUsername'])->first();
if ($user) {
if (Hash::check($data['doctorPassword'], $user->doctorPassword))
{
return view($this->filePath . '.doctorProfile');
}
请检查此 link:https://laravel.com/docs/5.8/hashing