为什么认证它不能在我的验证中工作并且它显示出任何错误

时间:2018-03-04 12:33:57

标签: laravel-5.6

我是laravel的新手,我不知道我的代码有什么不对,它没有重定向

public function login(Request $request){
   $this->validate($request, [
    'email'=> 'required|max:32',
    'password'=> 'required|confirmed|max:32|min:8',
  ]);
  if (Auth::attempt(['email'=>$request->email,'password'=>$request->password])) {
    return redirect('/welcome');
  }
  return "Oooops something wrong happen";
}

这是我的登录表单

<form action="login" method="post">
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <div class="form-group">
          <input type="email" name="" value="" class="form-control" placeholder="Enter Your Email">
        </div>
        <div class="form-group">
          <input type="password" name="" value="" class="form-control" placeholder="Enter Your password">
        </div>
        <div class="form-group">
          <input type="submit" name="" value="login" class="btn btn-success btn-lg btn-block">
        </div>

和我的路线

Route::post('/login', 'UserController@login');

1 个答案:

答案 0 :(得分:0)

您的表单错误,您的姓名值为空,并且您错过了确认密码字段

<form action="login" method="post">
       {{ csrf_field() }}
        <div class="form-group">
          <input type="email" name="email" class="form-control" placeholder="Enter Your Email">
        </div>
        <div class="form-group">
          <input type="password" name="passowrd" class="form-control" placeholder="Enter Your password">
        </div>  <div class="form-group">
          <input type="password" name="passowrd_confirmation" class="form-control" placeholder="Enter Your password">
        </div>
        <div class="form-group">
          <input type="submit" value="login" class="btn btn-success btn-lg btn-block">
        </div>    
</form>