Search code examples
phpmysqllaravellaravel-4laravel-3

Laravel 4: custom login and check password


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;
}

Now, we all know that password are hashed so you cant use password = ?. how can I check the password if it's correct?


Solution

  • You can use

    $password = Hash::make($password);
    

    function to get the hash of password, and then check it