I have some problem with 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. 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