Laravel 4:自定义登录并检查密码 [英] Laravel 4: custom login and check password
本文介绍了Laravel 4:自定义登录并检查密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想自定义laravel 4中的登录名,其中username
是他的username
或email
,所以我要做的是:
I would like to customize my login in laravel 4 where username
is either his username
or email
so what I did is:
public static function custom_login($uname,$pwd)
{
$res = DB::select("select * from users where (username = ? or email = ?) and password = ? and active = 1",array($uname,$uname,$pwd));
return $res;
}
现在,我们都知道密码是哈希值,所以您不能使用password = ?
.密码正确怎么办?
Now, we all know that password are hashed so you cant use password = ?
. how can I check the password if it's correct?
推荐答案
您可以使用
$password = Hash::make($password);
函数获取密码的哈希值,然后检查它
function to get the hash of password, and then check it
这篇关于Laravel 4:自定义登录并检查密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文