我使用md5来哈希我的密码,但了解到使用bcrypt更安全.
使用md5时,很容易检查表单中输入的密码是否正确.我干脆完成了
if(md5($request->password) == $user->password)
//Login or whatever
那么如何使用bcrypt来做到这一点?我试过了
if(bcrypt($request->password) == $user->password)
但这不起作用.
解决方法:
使用attempt()
方法:
if (Auth::attempt(['email' => $email, 'password' => $password]))
The
attempt
method accepts an array of key/value pairs as its first argument. The values in the array will be used to find the user in your database table.
https://laravel.com/docs/5.4/authentication#authenticating-users
在引擎盖下尝试()使用password_verify()
方法来检查密码.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。