糟糕的Auth ::尝试Laravel 5.2

时间:2016-04-21 16:50:03

标签: php laravel laravel-5.2

我对Auth ::尝试有些问题。当我写好用不良密码登录尝试登录到网站无论如何用错误的用户。为什么它不起作用?

方法:

public function postLogin(LoginRequest $request) {      
    if (Auth::attempt(["name" => $request["name"], "password" => $request["password"]])) {
        return Redirect::route("home");
    } else {
        return Redirect::route("home");
    }
}

LoginRequest

class LoginRequest extends Request {

public function rules() {
    return [
        "name" => "required|exists:users",
        "password" => "required",
    ];
}

public function messages(){
    return [
        "name.required" => "Login is empty.",
        "password.required" => "Password is empty.",
        "name.exists" => "User not found.",
    ];
}

}

我知道我重定向到相同的视图,但是视图有两个选项用于auth和!auth,但是当我登录时使用良好的登录名和密码错误时我看到了auth页面,其他选项也有效。我错了什么?

此致

编辑: 图

<form action={{ route("login") }} method="post">
                <input class="form-control" type="text" name="name" /><br />
                <input class="form-control" type="password" name="password" /><br />
                <input class="form-control" type="hidden" name="_token" value="{{ csrf_token() }}" /><br />
                Remember me! <input class="form-control" type="checkbox" name="remember_me" value=""/><br />
                <input class="btn btn-primary" type="submit" value="Zaloguj" />
            </form>

1 个答案:

答案 0 :(得分:0)

密码列名为“密码”?哈希?

您可以查看文档以获取更多信息。

https://laravel.com/docs/5.2/authentication#authenticating-users