令牌不匹配異常我隨後創建使用Laravel一個註冊和登錄頁面this教程。上登錄(Laravel)
一切正常,唯一的問題是我無法登錄。如果我提供了錯誤的用戶名/密碼,它正確地給了我一個錯誤信息。但是,如果使用正確的憑據,我碰到下面的錯誤 -
Illuminate \ Session \ TokenMismatchException
這是我的(默認)CSRF功能 -
Route::filter('csrf', function()
{
if (Session::token() != Input::get('_token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
});
這是形式的行動 -
{{ Form::open(array('url'=>'signin', 'class'=>'form-signin')) }}
這是我UsersController的相關部分
public function __construct() {
$this->beforeFilter('csrf', array('on'=>'post'));
$this->beforeFilter('auth', array('only'=>array('getDashboard')));
}
public function postSignin() {
if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password')))) {
return Redirect::to('dashboard')->with('message', 'You are now logged in!');
} else {
return Redirect::to('login')
->with('message', 'Your username/password combination was incorrect')
->withInput();
}
}
public function getDashboard() {
$this->layout->content = View::make('users.dashboard');
}
嘗試'DD(會話令牌::();'和'DD(輸入::獲得(「_令牌」)'在CSRF過濾器檢查哪一部分是缺少令牌 – Andreyco
問題隨機整流本身......哦哦。 –
您是否在表單中添加了此行? '' – captainblack