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]');
私は見ることができません例外の原因を絞り込む。ヘルプをいただければ幸いです。
なぜAuth \ LoginControllerではなくSessionControllerを通じてログインしていますか?ユーザー認証に別のパッケージを使用していますか? – btl
コントローラを一度変更してください –
'' php artisan route:list'を実行すると、ルータが/ loginルートのためにリストアップしているものが表示されます。 – btl