Reputation: 1521
I have this code which worked in previous versions, now doesn't work anymore. I'm doing simple user authourization like this:
Form:
{{ Form::open(array(
'url' => 'login',
'method' => 'PUT',
'class' => 'pure-form pure-form-stacked'
)) }}
{{ $errors->first('email') }}
{{ $errors->first('password') }}
{{ Form::text('email', Input::old('email'), array('placeholder' => 'user')) }}
{{ Form::password('password', array('placeholder' => 'password')) }}
{{ Form::submit('Log in', array('class'=>'button-primary')) }}
{{ Form::close() }}
Routes:
Route::get('login', array('https', function(){
return View::make('back-end/login');
}));
Route::post('login', array('https', function(){
$userdata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
if(Auth::attempt($userdata)){
return Redirect::to('dashboard');
} else {
return Redirect::to('login');
}
}));
Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function(){
Route::get('/', 'DashboardController@getDashboard');
Route::resource('blog', 'BlogController');
Route::get('logout', [
'as' => 'logout',
'uses' => 'UserController@getLogout'
]);
});
Login page will load, but when i submit form i get in output MethodNotAllowedHttpException.
Upvotes: 0
Views: 1809
Reputation: 180177
Your login route is a POST
, but your form is using PUT
. Switch 'method' => 'PUT',
to 'method' => 'POST',
in your Form::open
call (as you shouldn't be using PUT
anyways there) and it should work.
Upvotes: 3