我只在手机上获得此TokenMismatchException。
iOS 9.1 / iPhone 6 Plus / Safari
我已尝试添加此
******** D:\builds\gauntlet\main\cat\src\main\resources\node_modules\react-tools\src\vendor\core\warning.js
(function(){return function(module, exports, require, __dirname, __filename, global, jest, ____JEST_COVERAGE_DATA____) {/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule warning
*/
"use strict";
var emptyFunction = require('emptyFunction');
/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var warning = emptyFunction;
if (__DEV__) {
warning = function(condition, format, ...args) {
if (format === undefined) {
throw new Error(
'`warning(condition, format, ...args)` requires a warning ' +
'message argument'
);
}
这是我的登录表单
<meta name="csrf-token" content="{{ csrf_token() }}">
不在我的iPhone (iOS 9.1 / iPhone 6 Plus / Safari)上工作
但我仍然可以登录电脑/笔记本电脑。
HTML表格
{{ csrf_field() }}
有人知道为什么会这样吗?
更新
适用于iPhone 6 Plus iOS 9.1上的Chrome。
答案 0 :(得分:0)
根据您的评论和更新的问题,您可以通过编辑app/Http/Kernel.php
文件来禁用csrf检查。
只需在VerifyCsrfToken
数组
protected $Middleware
第二种方法:
我将从我的应用程序中添加一小段代码并解释一下。
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(register_url);
HttpGet httpGet = new HttpGet(token_url);
try {
// first hit on the server url to get csrf token
ResponseHandler<String> tokenHandler = new BasicResponseHandler();
csrf_token = httpClient.execute(httpGet, tokenHandler);
// Obtained Token, now we can make post call
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("_token", csrf_token));
nameValuePairs.add(new BasicNameValuePair("_device", device_id));
nameValuePairs.add(new BasicNameValuePair("username", username));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> mHandler = new BasicResponseHandler();
response = httpClient.execute(httpPost, mHandler);
此代码属于我的某个Android应用程序(是的,DefaultHttpClient
现已弃用)。我编写了一个API端点,它从服务器返回一个csrf_token,即csrf_token
变量,url存储在token_url
中。收到csrf令牌后,我将POST
用csrf_token
作为_token
进行实际的public function index()
{
return csrf_token();
}
来电。
我希望代码能够解释。
在您的laravel代码中,您可以返回csrf_token,如下所示
Calendar
答案 1 :(得分:0)
在对Safari特定问题进行更多研究后,我了解到我需要调整 Cookie 设置。
步骤:
Settings
Safari
Block Cookies
Always Allow