2017-06-17 52 views
0

我正在顯示一個表單,如果用戶未通過身份驗證,則會顯示一個將啓動模態登錄表單的按鈕。Laravel Modal登錄會產生MethodNotAllowedHttpException,但會進行身份驗證

我輸入有效的憑據並體驗MethodNotAllowedHttpException。不過,我已經過認證。在另一個選項卡(或回擊和重裝)

(1/1) MethodNotAllowedHttpException 
    in RouteCollection.php (line 251) 
    at RouteCollection->methodNotAllowed(array('POST')) 
    in RouteCollection.php (line 238) 

我的模式形式:

  <form class="form-horizontal" role="form" method="POST" action="{{ route('login') }}"> 
       {{ csrf_field() }} 
       <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}"> 
        <label for="email" class="col-md-4 control-label">E-Mail Address</label> 
        <div class="col-md-6"> 
         <input id="email" type="email" class="form-control" name="email" 
           value="{{ old('email') }}" required autofocus> 
         @if ($errors->has('email')) 
          <span class="help-block"> 
            <strong>{{ $errors->first('email') }}</strong></span> 
         @endif 
        </div></div> 
       <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}"> 
        <label for="password" class="col-md-4 control-label">Password</label> 
        <div class="col-md-6"> 
         <input id="password" type="password" class="form-control" name="password" required> 
         @if ($errors->has('password')) 
          <span class="help-block"> 
            <strong>{{ $errors->first('password') }}</strong></span> 
         @endif 
        </div></div> 
       <div class="form-group"> 
        <div class="col-md-6 col-md-offset-4"> 
         <div class="checkbox"> 
          <label> <input type="checkbox" 
             name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me</label></div></div></div> 
       <div class="form-group"> 
        <div class="col-md-8 col-md-offset-4"> 
         <button type="submit" class="btn btn-primary">Login</button> 
         <a href="#reset_modal" class="btn btn-link" data-toggle="modal" data-dismiss="modal" data-target="#reset_modal"> 
          Forgot Your Password?</a></div></div></form> 
我SessionController.php的

相關部分:

public function store (Request $request) { 
    if (! auth()->attempt(request(['email', 'password']))) { 
     return back(); 
    } 
    return redirect('/dashboard'); 
} 

相關路線:

Route::post('/login', '[email protected]'); 

我不能他們將原因縮小爲例外。幫助將不勝感激。

+0

爲什麼通過SessionController而不是Auth \ LoginController登錄?您是否使用其他軟件包進行用戶身份驗證? – btl

+0

更換您的控制器一次 –

+1

運行'php artisan route:list'來查看路由器爲/ login路由列出的內容。 – btl

回答

0

這是一個問題,由於反饋嘗試回發到頁面(源自一個帖子表單),通過返回這是一個GET字符串。所以路由錯誤是由於這個。

我希望有一種方法可以使用POST重定向回來。