久久久久久久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的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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...

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

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 中查看會發(fā)生什么.每次提交表單后,我都會收到一條消息,提示重定向到:/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.

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

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'));

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

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

var_dump(Session::all());

{{{ csrf_token() }}}

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

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 令牌檢查 將被刪除,這意味著您的網(wǎng)站將不受保護(hù)跨站點請求偽造.

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.

更新根據(jù)文檔,您應(yīng)該通過將此代碼段添加到您的代碼中來將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() }}">

我在移動應(yīng)用程序的后端服務(wù)中使用了第一種方式,但我發(fā)現(xiàn)我可以在請求中發(fā)送 CSRF 標(biāo)頭.

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

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

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

相關(guān)文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數(shù))
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數(shù)中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應(yīng)內(nèi)容必須是實現(xiàn) __toString()、“boolean和“boolean的字符串或?qū)ο?移動到 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())
主站蜘蛛池模板: 视频国产一区 | 伊人春色在线观看 | 麻豆一区| 国产高清视频 | 狠狠干av | 国产精品久久久久久 | 蜜臀av日日欢夜夜爽一区 | 欧美成年网站 | 青青久在线视频 | av黄色在线| 亚洲精品自在在线观看 | 国产精品久久久久久一区二区三区 | 国产精品一区二区免费 | 狠狠影院 | 国产精品一二三区在线观看 | 国产午夜精品一区二区三区四区 | 美女天天操 | 日韩电影中文字幕在线观看 | 成人一区二区在线 | 国产精品波多野结衣 | 中文在线观看视频 | 中文字幕av在线播放 | 自拍偷拍中文字幕 | 在线播放亚洲 | 久久久久欧美 | 一区二区三区视频在线免费观看 | 亚洲精选久久 | 一区二区三区电影网 | 日韩成人免费 | 精品久久久久久一区二区 | 免费av观看 | 久久91精品国产一区二区 | 成人区精品 | 中文字幕日本一区二区 | 毛片av免费看| 最新av片| 亚洲国产精品一区二区三区 | 欧美日韩亚 | 日本成人毛片 | 久久亚洲精品国产精品紫薇 | 日一区二区 |