dqydp44800 2017-05-12 14:33
浏览 41
已采纳

提交表单时重定向到错误的路由

I am submitting my login form and define the route action="{{route('signin')}}" but it is redirecting the user to the login route.

form code is here .

<form  action="{{route('signin')}}" method="post" role="form">

                   <div class="form-group {{ $errors->has('email') ? ' has-error' : '' }}">
                       <label>Enter Email : </label>

                           <input placeholder="Enter Email" name="email" type="text" class="form-control" value="{{Request::old('email')}}">
                           @if ($errors->has('email'))
                               <span class="help-block">
                                <strong>{{ $errors->first('email') }}</strong>
                            </span>
                           @endif

                    </div>


                    <div class="form-group {{ $errors->has('password') ? ' has-error' : '' }}">
                        <label>Enter  Password :</label>
                        <input placeholder="Enter Password" type="password" name="password" class="form-control" value="{{Request::old('password')}}">
                           @if ($errors->has('password'))
                               <span class="help-block">
                                <strong>{{ $errors->first('password') }}</strong>
                            </span>
                           @endif

                    </div>

                {{csrf_field()}}
                    <input class="btn btn-outline btn-danger" type="submit" value="submit" title="Login">


            </form>

Code in routes is here .

 Route::get('/login',[
    'uses' => 'userController@user',
    'as' => 'login'
]);
 Route::post('/signin',[
    'uses' => 'userController@postSignIn',
    'as' => 'signin',
    'middleware'=>'auth',
]);
  • 写回答

2条回答 默认 最新

  • dongmi4927 2017-05-12 14:54
    关注
    Route::post('/signin',[
        'uses' => 'userController@postSignIn',
        'as' => 'signin'
    ]);
    

    Just remove the "auth" middleware as it doesnt allow access to the method before sign in.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?