Laravel 5.5 error when try to login

2019-07-30 02:22发布

问题:

i'm trying to create a custom check with laravel. I adding this in LoginController

  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')); 
              }

        }

and here is my route

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

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::get('customchecker','LoginController@customchecker')->name('customchecker');

But i get an error , here is my error

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

so, how can i fix this ?

回答1:

Your customchecker route is declared as GET, make sure you are using the same action and not POST or something else.