gpt4 book ai didi

laravel - Hash::check() 总是返回 false

转载 作者:行者123 更新时间:2023-12-02 15:51:17 26 4
gpt4 key购买 nike

我试图检查用户登录时输入的密码以及数据库中的哈希密码,但它总是返回 false。

这是 Controller 中对密码进行哈希处理的代码

$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');
}

}

始终返回 false。

最佳答案

您的参数顺序不正确。您应该首先添加纯文本版本的密码,如下所示:

Hash::check($data['doctorPassword'], $user->doctorPassword);

关于laravel - Hash::check() 总是返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55337701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com