【问题标题】:laravel 5.1 error TokenMismatchException in VerifyCsrfToken.php line 53:laravel 5.1 在 VerifyCsrfToken.php 第 53 行出现错误 TokenMismatchException:
【发布时间】:2016-01-02 04:14:52
【问题描述】:

我尝试对用户进行身份验证。我输入代码并执行文档 laravel 之类的步骤,但出现错误。这是我的表格

在此处输入代码

{!! csrf_field() !!} 
First Name Last Name E-mail Address Sport: {{ $gametype }}>   
@foreach($games as $game) 
    <input type="checkbox" value="{{ old('game_type_id') }}"> {{ $game->name }}>
@endforeach 

密码 密码确认 我同意使用条款 注册 注册 或 Connect with Connect with 已经有一个帐户?登录!

这是路由: // 身份验证路由...

Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');      
Route::get('auth/logout', 'Auth\AuthController@getLogout');

//注册路由...

Route::get('auth/register', 'Auth\AuthController@getRegister'); 
Route::post('auth/register', 'Auth\AuthController@postRegister');

我的文件登录和注册刀片位于 view/auth 文件夹中。当我注册时,在 VerifyCsrfToken.php 第 53 行收到此错误 TokenMismatchException:

【问题讨论】:

    标签: php authentication laravel-5 token


    【解决方案1】:

    根据官方文档here,您必须使用和输入当前令牌的字段。

    <input type="hidden" name="_token" value="{{csrf_token()}}" />
    

    并使用Route::controller('auth','AuthController'); 而不是您当前的所有路线。

    【讨论】:

      猜你喜欢
      • 2016-06-29
      • 2016-03-03
      • 2015-09-05
      • 2016-09-02
      • 2016-03-20
      • 2015-11-07
      • 2017-07-20
      • 1970-01-01
      • 2016-01-04
      相关资源
      最近更新 更多