2014-06-09 74 views
0

我有這個代碼在以前的版本工作,現在不再工作。我在做簡單的用戶authourization這樣的:Laravel 4.2拋出MethodNotAllowedHttpException

形式:

{{ 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() }} 

路線:

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('/', '[email protected]'); 
    Route::resource('blog', 'BlogController'); 
    Route::get('logout', [ 
      'as' => 'logout', 
      'uses' => '[email protected]' 
     ]); 
}); 

登錄頁面將加載,但是當我提交I​​輸出MethodNotAllowedHttpException得到。

+0

將方法從'put'改爲'post'。 – itachi

回答

3

您的登錄路線是POST,但您的表單正在使用PUT。在Form::open電話中撥'method' => 'PUT','method' => 'POST',(因爲您不應該在那裏使用PUT),它應該可以工作。

+0

我做到了,但後來我得到「404未找到」。 – Jack

+1

'php artisan routes'輸出是什麼? – ceejayoz

+0

所有的路由都存在,這是沒有意義的,如果憑據是錯誤的,它應該重新加載登錄頁面,而不是拋出找不到錯誤。 – Jack

相關問題