Skip to content

Commit

Permalink
Merge pull request #1020 from ctidigital/wishlist
Browse files Browse the repository at this point in the history
Add the form key to wishlist submit to prevent 403 errors.
  • Loading branch information
miguelbalparda committed Nov 25, 2015
2 parents 13a7988 + 8a788e8 commit ba1d95e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ public function hookToControllerActionPreDispatch($observer) {
if (Mage::helper('turpentine/data')->getVclFix() == 0 && $observer->getEvent()->getControllerAction()->getFullActionName() == 'checkout_cart_add') {
Mage::dispatchEvent("add_to_cart_before", array('request' => $observer->getControllerAction()->getRequest()));
}
if ($observer->getEvent()->getControllerAction()->getFullActionName() == 'wishlist_index_index') {
Mage::dispatchEvent('wishlist_index_index_before', array('request' => $observer->getControllerAction()->getRequest()));
}
}

public function hookToControllerActionPostDispatch($observer) {
Expand All @@ -552,4 +555,18 @@ public function hookToAddToCartAfter($observer) {
$request = $observer->getEvent()->getRequest()->getParams();
//Mage::log("hookToAddToCartAfter ".print_r($request,true)." is added to cart.", null, 'carrinho.log', true);
}

/**
* Set the form key on the add to wishlist request
*
* @param $observer
*
* @return Nexcessnet_Turpentine_Model_Observer_Esi
*/
public function hookToAddToWishlistBefore($observer)
{
$key = Mage::getSingleton('core/session')->getFormKey();
$observer->getEvent()->getRequest()->setParam('form_key', $key);
return $this;
}
}
8 changes: 8 additions & 0 deletions app/code/community/Nexcessnet/Turpentine/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,14 @@
</add_to_cart_after>
</observers>
</add_to_cart_after-->
<wishlist_index_index_before>
<observers>
<wishlist_index_index_before>
<class>turpentine/observer_esi</class>
><method>hookToAddToWishlistBefore</method>
</wishlist_index_index_before>
</observers>
</wishlist_index_index_before>
</events>
</frontend>
<admin>
Expand Down

0 comments on commit ba1d95e

Please sign in to comment.