简体   繁体   English

Laravel 5.2中错误的Auth :: attempt

[英]bad Auth::attempt in Laravel 5.2

I have some problem with Auth::attempt. 我对Auth :: attempt有一些问题。 When i write good Login with bad password attempt login into website anyway with wrong user. 当我用错误的密码编写良好的登录名后,无论如何都要以错误的用户身份登录网站。 Why it dont work ? 为什么不起作用?

Method: 方法:

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.",
    ];
}

} }

I know i redirect to same view, but view have 2 options for auth and !auth, but I see auth page when I login with good login and bad password, other options works. 我知道我重定向到同一视图,但是视图有2个用于auth和!auth的选项,但是当我使用良好的登录名和错误的密码登录时,会看到auth页面,其他选项有效。 What did I wrong ? 我怎么了?

Regards 问候

edit: view 编辑视图

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

the password column is named "password" ? 密码列名为“密码”? and is hashed? 并散列?

you can see the doc for more information. 您可以查看该文档以获取更多信息。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM