Auth :: attempt()总是返回false

时间:2018-05-21 17:36:51

标签: authentication laravel-5

alaways返回错误的值,但是值得通过$ request正确我该怎么办?

    public function login(Request $request)
    {
        $email = $request->input('email');//singh@gmail.com
        $password = $request->input('password');//a

        //$input = ['email'=>$email,'password'=>$password];

        if (Auth::attempt(['email'=>'singhkulpreet05@gmail.com','password'=>$password])) {
            return "logged in";
        }
        else return "notttt";
    }

1 个答案:

答案 0 :(得分:0)

好吧,首先检查你的数据库以及下面的代码是否适合我。你可以尝试一下吗?希望它能奏效。

public function postLogin(Request $request){

    if (Auth::attempt(array('email' => $request->input('email'), 'password' => $request->input('password')))){
        return "logged in"; 
    }

    return "notttt";
}