2017-06-17 7 views
0

Ich zeige ein Formular an, wo, wenn der Benutzer nicht authentifiziert wird, gibt es eine Schaltfläche, die ein modales Login-Formular startet.Laravel Modal login erzeugt MethodNotAllowedHttpException aber authentifiziert

Ich gebe gültige Anmeldeinformationen ein und erlebe eine MethodNotAllowedHttpException. Ich bin jedoch authentifiziert. In einer anderen Registerkarte (oder durch Schlagen zurück und Nachladen)

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

Meine modale Form:

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

Relevante Teil meiner SessionController.php:

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

Relevante Route:

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

Ich kann nicht se em, um die Ursache auf die Ausnahme einzugrenzen. Hilfe wäre willkommen.

+0

Warum melden Sie sich über den SessionController an, im Gegensatz zu Auth \ LoginController? Verwenden Sie ein anderes Paket für die Benutzerauthentifizierung? – btl

+0

Ändern Sie Ihren Controller einmal –

+1

Führen Sie 'php artisan route: list' aus, um zu sehen, was der Router für die Route/login aufgelistet hat. – btl

Antwort

0

Dies war ein Fall von einem Problem aufgrund von Feedback versucht, zurück auf die Seite (stammt aus einem Post-Formular) über zurück, die eine GET-Zeichenfolge ist. Also der Routenfehler war darauf zurückzuführen.

Ich wünschte, es gäbe eine Möglichkeit, zurück mit POST umleiten.

Verwandte Themen