From 03ac5b5b9f66dea7b50eccd4ee275579c50c5ebe Mon Sep 17 00:00:00 2001 From: Oscar Recio Date: Sun, 5 Nov 2017 13:23:21 +0100 Subject: [PATCH] Generate new FormKey and replace for oldRequestParams --- .../Model/Plugin/CustomerFlushFormKey.php | 53 +++++++++++++++++++ app/code/Magento/Customer/etc/di.xml | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 app/code/Magento/Customer/Model/Plugin/CustomerFlushFormKey.php diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerFlushFormKey.php b/app/code/Magento/Customer/Model/Plugin/CustomerFlushFormKey.php new file mode 100644 index 0000000000000..b7b462b3cc317 --- /dev/null +++ b/app/code/Magento/Customer/Model/Plugin/CustomerFlushFormKey.php @@ -0,0 +1,53 @@ +session = $session; + $this->dataFormKey = $dataFormKey; + } + + /** + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @param FlushFormKey $subject + * @param callable $proceed + * @param $args + */ + public function aroundExecute(FlushFormKey $subject, callable $proceed, ...$args) + { + $currentFormKey = $this->dataFormKey->getFormKey(); + $proceed(...$args); + $beforeParams = $this->session->getBeforeRequestParams(); + if ($beforeParams['form_key'] == $currentFormKey) { + $beforeParams['form_key'] = $this->dataFormKey->getFormKey(); + $this->session->setBeforeRequestParams($beforeParams); + } + } +} diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 6eea4e1582a97..40ef730120783 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -323,6 +323,9 @@ + + + Magento\Customer\Model\Cache\Type\Notification