2017-11-01 19 views
1

laravelでカスタムチェックを作成しようとしています。私はLoginControllerログインしようとするとLaravel 5.5エラーが発生する

public function customchecker() 
     { 


      $credentials = [ 
       'username'  => Input::get('username'), 
       'password'  => Input::get('password')  
      ]; 

      if (Auth::attempt($credentials)) { 
        return Redirect::to('account')->with('alert-success', 'You are now logged in.'); 

       $errors = new MessageBag(['password' => ['Email and/or password invalid.']]); 

       return Redirect::back()->withErrors($errors)->withInput(Input::except('password')); 
       } 

     } 

でこれを追加し、ここに私のルートは

Route::get('/', function() { 
    return view('welcome'); 
}); 

Auth::routes(); 

Route::get('/home', '[email protected]')->name('home'); 

Route::get('customchecker','[email protected]')->name('customchecker'); 

ですが、私はエラーを取得し、ここで私の誤差が MethodNotAllowedHttpException \

のSymfony \コンポーネント\ HttpKernel \例外です メッセージなし

だから、どうすれば修正できますか?

+0

条件を確認してください。 Auth :: attempt($ credentials)がtrueの場合、リダイレクトは2回実行されます。問題を引き起こす可能性があります! –

+0

あなたは普通のパスワードも返しているようです。これをbcrypt()を使って暗号化していませんか? – Option

答えて

1

あなたのcustomcheckerルートはGETと宣言されていますが、同じアクションを使用していて、POSTなどではないことを確認してください。

関連する問題