Laravel Spark: CSRF Failure on Login Page

折月煮酒 提交于 2019-12-23 01:12:46

问题


Using Laravel Spark (or any Laravel login form with CSRF protection), if a user leaves the login page open for a period of time (like, say, leaving the window open at work and returning to it later) and then attempts to login, they're presented with an error.

Whoops, looks like something went wrong.

(1/1) TokenMismatchException in VerifyCsrfToken.php (line 68)

This makes sense, as CSRF tokens are date/time sensitive. However, the user experience here is less than ideal.

Before we go reinventing the wheel. Is there any Laravel Standard Practice™ for providing a better user experience around this? Or does everyone just roll their own CSRF middleware/middlewares that fails in a more friendly way?


回答1:


This is changing in Laravel 5.5. The TokenMismatchException is now producing a more elegant error page informing the user that the page has expired due to inactivity and advising them to refresh and try again.

So what you're doing is probably the Laravel Standard Practice™ now :)



来源:https://stackoverflow.com/questions/45575735/laravel-spark-csrf-failure-on-login-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!