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

Laravel 5 Auth Post Submit - VerifyCsrfToken.php 第 46 行中的

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

問題描述

剛剛在 Laravel 5 中開發了一個新應用程序,我在使用開箱即用的身份驗證時遇到了一些問題...

Have just statred a new app in Laravel 5 and I am having some trouble using the out of the box auth...

我不斷收到:VerifyCsrfToken.php 第 46 行中的 TokenMismatchException:在提交登錄或注冊表單時...

I keep getting : TokenMismatchException in VerifyCsrfToken.php line 46: on submitting the login or signup forms...

我可以在登錄表單頁面上看到隱藏表單字段中的令牌代碼和當時的會話是相同的...

I can see on the login form page the token codes that are in the hidden form field and Session at that point are the same...

作為測試,我也嘗試過,因為其他一些帖子建議將其注釋掉//'AppHttpMiddlewareVerifyCsrfToken',在 app/Http/kernal.php 中查看會發生什么.每次提交表單后,我都會收到一條消息,提示重定向到:/auth/login 或/auth/register,具體取決于我來自哪里,但沒有成功.

As a test I have also tried as some other posts suggested commenting out //'AppHttpMiddlewareVerifyCsrfToken', in app/Http/kernal.php to see what would happen. After doing this every time I submit a form I get a message which says redirecting to: /auth/login or /auth/register depending on where I came from with no success.

奇怪的是,當我第一次安裝這個框架時,它就起作用了.從那時起,我所做的就是運行一些遷移并設置我的一些模型和控制器,并將一些用戶數據植入數據庫.

The weird thing was this was working when I first installed the framework. All I have done since then is run a few migrations and setup some of my models and controllers and seeded the db with some user data.

更新:

如果我:

var_dump($request->session()->token());

var_dump($request->input('_token'));

我可以看到兩個標記不同,但在使用的表單中:

I can see the two tokens are different but at the form using:

var_dump(Session::all());

{{{ csrf_token() }}}

它們是一樣的.Session 令牌在到達 VerifyCsrfToken.php 的第 55 行的函數 tokensMatch() 之前發生了一些變化

They are the same. The Session token has changed some how before it gets to the function tokensMatch() on line 55 of VerifyCsrfToken.php

我的堆棧跟蹤如下:

in VerifyCsrfToken.php line 46
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->IlluminatePipeline{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->IlluminatePipeline{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->IlluminatePipeline{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->IlluminatePipeline{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->IlluminatePipeline{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->IlluminatePipeline{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53

推薦答案

我剛開始工作時刪除了該行:

I first just got it working removing the line:

'IlluminateFoundationHttpMiddlewareVerifyCsrfToken'

'IlluminateFoundationHttpMiddlewareVerifyCsrfToken'

來自/app/Http/Resquests/Kernel.php.但是,這意味著 CSRF 令牌檢查 將被刪除,這意味著您的網站將不受保護跨站點請求偽造.

from /app/Http/Resquests/Kernel.php. However, this means the CSRF token check will be removed, which implies that your website will not be protected from cross-site request forgeries.

更新根據文檔,您應該通過將此代碼段添加到您的代碼中來將CSRF令牌添加到您的表單中:

Update According to the documentation, you should add the CSRF token to your form by adding this snippet to your code:

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

我在移動應用程序的后端服務中使用了第一種方式,但我發現我可以在請求中發送 CSRF 標頭.

I used first way in backend services for mobile application but I find I can send send CSRF header within requests.

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

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

相關文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數)
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應內容必須是實現 __toString()、“boolean和“boolean的字符串或對象.移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 久久三区 | 亚洲青涩| 特级丰满少妇一级aaaa爱毛片 | 欧美性猛交xxxx黑人猛交 | 久草福利 | 一区二区免费在线观看 | 又色又爽又黄18网站 | 亚洲成人精品在线观看 | 天天操夜 | a毛片大片| 97色婷婷| 欧美精产国品一二三区 | 一区二区影视 | 精品视频在线免费观看 | 可以看的毛片 | 伊人网综合| 中文在线字幕观看 | 中文字幕少妇 | 91狠狠干| 国产美女视频网站 | 视频一区二区三区在线观看 | 欧美一级精品 | 成人免费高清 | 欧美国产在线观看 | 亚洲一区中文 | 亚洲天天操 | 一区二区高清视频 | 国产一区福利 | 国产aa视频| 免费观看黄色av | 亚洲免费成人 | 久草热视频 | 日韩免费在线观看 | 亚洲视频不卡 | 黄色日本视频 | 日韩成人免费 | sm调教视频永久免费 | 欧美黄色一区二区 | 亚洲狠狠干 | 欧美一区二区三区视频 | 欧美日韩成人一区二区 |