Reputation: 61
I am trying to POST a form BEFORE user authentication. User inputs data into a form and POST it to the route protected by auth:
Route::group(['middleware'=>'auth'], function(){ Route::post('v2/payment/start/','PaymentController@generic');
});
If a user IS authenticated BEFORE the POST, the request is processed OK. If a user is NOT authenticated, user gets the login form, enters login password and receives the error "MethodNotAllowedHttpException".
What could be the cause of this? In my LoginController I have:
return redirect()->intended($this->redirectPath());
so, the user should be redirected OK.
Where could be the error?
Upvotes: 0
Views: 149
Reputation: 111829
The problem is that after user is authenticated, they will be redirected using GET
method (redirections always use GET method). So you can try to use:
Route::match(['get', 'post'], 'v2/payment/start/','PaymentController@generic');
instead of
Route::post('v2/payment/start/','PaymentController@generic');
to make this route working with both GET
and POST
methods.
Upvotes: 2