问题描述
所以,我正在为我的网站切换到 laravel.我的旧网站目前拥有大约 500 个用户.每个用户都有一个 md5 哈希作为密码 (duh ^^).
So, I'm switching over to laravel for my site. My old site currently holds around 500 users. Each user has a md5 hash attached to them, as the password (duh ^^).
当我切换到 laravel 时,我希望使用 Auth::attempt不幸的是,它使用自己的方法来散列密码字符串.我不希望我的所有用户都更改密码,因为我正在切换到 laravel,是否可以让 Auth 类使用 md5 代替,所以我的用户不必切换密码?:)
As I'm switching over to laravel, I wish to use the Auth::attempt unfortunately it uses its own method to hash password strings. I don't want all my users to change their password, because I'm switching to laravel, is it possible to make the Auth class use md5 instead, so my users don't have to switch password? :)
如果是,谁能告诉我怎么做?
If yes, can someone show me how?
推荐答案
MD5 已经过时了.我建议你不要试图保留它.相反,当用户第一次登录,并且 Auth::attempt 失败时,您应该尝试将他们的密码与数据库进行比较 MD5
MD5 is horribly outdated. I recommend that you don't try to keep it.
Instead, when a user first logs in, and Auth::attempt fails, you should then try to compare their password to the database as MD5
$user = User::where('username', '=', Input::get('username'))->first();
if(isset($user)) {
if($user->password == md5(Input::get('password'))) { // If their password is still MD5
$user->password = Hash::make(Input::get('password')); // Convert to new format
$user->save();
Auth::login(Input::get('username'));
}
}
这篇关于Laravel Auth - 使用 md5 代替集成的 Hash::make()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)