久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Laravel 5.1 中 VerifyCsrfToken.php 第 53 行中的 TokenMis

TokenMismatchException in VerifyCsrfToken.php line 53 in Laravel 5.1(Laravel 5.1 中 VerifyCsrfToken.php 第 53 行中的 TokenMismatchException)
本文介紹了Laravel 5.1 中 VerifyCsrfToken.php 第 53 行中的 TokenMismatchException的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

當我嘗試登錄時顯示令牌錯誤.我在視圖中檢查了令牌是正確的,當評論 AppHttpMiddlewareVerifyCsrfToken::class 時,在 Kernel.php 它讓我登錄,但重定向到我的儀表板后我沒有登錄.我在 mac 上使用 MAMP.

<h1>登錄</h1><div>{!!Form::open(['url'=>'user/login','class' =>'']) !!}<input type="hidden" name="_token" value="{{ csrf_token() }}"><ul><li><label>客戶代碼</label>{!!Form::Text('customer_code',Input::old('customer_code'),['class'=>''])!!}<li><label>密碼</label>{!!Form::Password('password','',['class'=>''])!!}</li><li>{!!Form::submit('Submit',array('class' => 'btn')) !!}</li>{!!表格::關閉()!!}

<div><a href="{!!URL::to('user/forget_password')!!}">忘記密碼</a></div>

同時我使用Sentry Package登錄.

/*** 登錄后*/公共函數 post_login(){嘗試{$規則= ['customer_code' =>'必需的','密碼' =>'必需的',];$消息 = ['customer_code.required' =>'錯誤1','password.required' =>'error2'];$validator = Validator::make(Input::all(), $rules,$message);如果 ($validator->fails()){return Redirect::back()->withErrors($validator)->withInput();}//如果 ($validator->fails())別的{$authUser = Sentry::authenticateAndRemember(array('customer_code' =>Input::get('customer_code'),'密碼' =>Input::get('password')), false);如果($ authUser){//$login = Sentry::loginAndRemember($authUser);return Redirect::to('user/panel/'.$authUser->id)->with('comment', 'Welcome');}別的{return Redirect::back()->with('comment', '登錄錯誤');}}//驗證器}catch(Exception $e){return Redirect::back()->withInput(Input::except('password','file'))->withErrors(['ERROR!!!!!']);}}

解決方案

由于您使用的是表單構建器,因此請從表單中刪除它.當您執行 Form::open()

時,Laravel 表單構建器會自動向您的表單添加一個隱藏的令牌字段

所以刪除這一行:

 

When I try to login show me token error. I have checked token in view form it's right and when comment AppHttpMiddlewareVerifyCsrfToken::class, in the Kernel.php it makes me login but after Redirect to my dashboard I'm not logged in. I am using MAMP on mac.

<div>
    <h1>Login</h1>
    <div>
        {!! Form::open(['url'=>'user/login','class' => '']) !!}
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <ul>
          <li><label>Customer Code</label>{!!Form::Text('customer_code',Input::old('customer_code'),['class'=>''])!!}</li>
          <li><label>Password</label>{!!Form::Password('password','',['class'=>''])!!}</li>
          <li>{!! Form::submit('Submit',array('class' => 'btn')) !!}</li>
        </ul> 
        {!!Form::close()!!}
    </div>
    <div><a href="{!!URL::to('user/forget_password')!!}">Forget Password</a></div>
</div>

Meanwhile I use Sentry Package for login.

    /**
     * post_login
     */
    public function post_login()
    { 
        try
        {
            $rules  = [ 
                    'customer_code'         => 'required',
                    'password'              => 'required',
                ] ;                    
            $message = [ 
                    'customer_code.required'             => 'erorrr1',
                    'password.required'                =>'error2'    
                             ];                            
            $validator = Validator::make(Input::all(), $rules,$message);
            if ($validator->fails())
            {            
                return Redirect::back()->withErrors($validator)->withInput();        
            } // if ($validator->fails())
            else
            {
            $authUser = Sentry::authenticateAndRemember(array(
                                      'customer_code'    => Input::get('customer_code'),
                                      'password' => Input::get('password')), false);

                           if($authUser) 
                           {
                                //$login = Sentry::loginAndRemember($authUser);
                                 return Redirect::to('user/panel/'.$authUser->id)->with('comment', 'Welcome');
                           }
                           else
                           {
                             return Redirect::back()->with('comment', 'Error for login');
                           }
            }//validator                           
        }
         catch(Exception $e)
         {
             return Redirect::back()->withInput(Input::except('password','file'))->withErrors(['ERROR!!!!!']);
         }
}

解決方案

Edited:

Since you are using Form builder remove this from your form. Laravel form builder automatically adds a hidden token field to your form when you do Form::open()

So remove this line:

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

這篇關于Laravel 5.1 中 VerifyCsrfToken.php 第 53 行中的 TokenMismatchException的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

add new element in laravel collection object(在 Laravel 集合對象中添加新元素)
Creating an edit modal in Laravel 5(在 Laravel 5 中創建編輯模式)
Laravel 5.5 API resources for collections (standalone data)(用于集合的 Laravel 5.5 API 資源(獨立數據))
What is the best practice to create a custom helper function in php Laravel 5?(在 php Laravel 5 中創建自定義輔助函數的最佳實踐是什么?)
No #39;Access-Control-Allow-Origin#39; header - Laravel(沒有“Access-Control-Allow-Origin標頭 - Laravel)
Laravel Passport Route redirects to login page(Laravel Passport Route 重定向到登錄頁面)
主站蜘蛛池模板: 欧美aⅴ| 亚州中文字幕 | 一级二级三级在线观看 | 久久久久黄色 | 999精品视频 | 黄视频免费观看 | 成人一区二区三区在线观看 | 亚洲精品福利在线 | 国产一级在线观看 | 成人国产精品久久 | 欧美激情一区二区三级高清视频 | 99精品久久久久久 | 狠狠色狠狠色综合日日92 | 日本aaa视频| 妞干网视频 | 日本三级电影免费 | 超碰成人免费 | 人人人人干 | jlzzjlzz欧美大全 | 欧美久久久久 | 在线观看精品视频网站 | 日韩久久久久久久久久久 | 欧美精品在线一区二区三区 | 欧美一级在线观看 | 美日韩精品 | 精品国产一级 | 免费看a | 毛片a级毛片免费播放100 | 国产色婷婷久久99精品91 | 作爱视频免费看 | 国产精品国产三级国产aⅴ浪潮 | 亚洲欧美综合精品久久成人 | 国产亚洲精品久久情网 | 中文字幕 国产精品 | 精品一区二区在线看 | 亚洲视频在线看 | 国产成人99久久亚洲综合精品 | a在线视频 | 日本精品一区二区三区在线观看视频 | 久久国产欧美日韩精品 | 亚洲a视频 |