Skip to content

Commit 421b92c

Browse files
committed
MAGETWO-51910: CSRF delete the cart items
1 parent e756ebe commit 421b92c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
public function execute()
6161
{
6262
if (!$this->getFormKeyValidator()->validate($this->getRequest())) {
63-
return $this->resultRedirectFactory->create()->setPath('*/*/');
63+
return $this->resultRedirectFactory->create()->setPath('*/cart/');
6464
}
6565
$itemId = (int)$this->getRequest()->getParam('item_id');
6666
try {

app/code/Magento/Checkout/view/frontend/web/js/sidebar.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ define([
1212
'Magento_Ui/js/modal/confirm',
1313
'jquery/ui',
1414
'mage/decorate',
15-
'mage/collapsible'
15+
'mage/collapsible',
16+
'mage/cookies'
1617
], function ($, authenticationPopup, customerData, alert, confirm) {
1718

1819
$.widget('mage.sidebar', {
@@ -190,12 +191,16 @@ define([
190191
},
191192

192193
/**
193-
* @param url - ajax url
194-
* @param data - post data for ajax call
195-
* @param elem - element that initiated the event
196-
* @param callback - callback method to execute after AJAX success
194+
* @param {String} url - ajax url
195+
* @param {Object} data - post data for ajax call
196+
* @param {Object} elem - element that initiated the event
197+
* @param {Function} callback - callback method to execute after AJAX success
197198
*/
198199
_ajax: function (url, data, elem, callback) {
200+
$.extend(data, {
201+
'form_key': $.mage.cookies.get('form_key')
202+
});
203+
199204
$.ajax({
200205
url: url,
201206
data: data,

0 commit comments

Comments
 (0)