From a15f33557d72d4ab05a99e9583fbfc0e2daa2ba2 Mon Sep 17 00:00:00 2001 From: Alex Lukyanau Date: Sun, 15 Sep 2019 16:12:58 -0400 Subject: [PATCH] Fix for the issue #24547 --- .../Customer/Model/Account/Redirect.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 app/code/Magento/Customer/Model/Account/Redirect.php diff --git a/app/code/Magento/Customer/Model/Account/Redirect.php b/app/code/Magento/Customer/Model/Account/Redirect.php old mode 100644 new mode 100755 index 2ccaaea45680c..b9a669b8ba990 --- a/app/code/Magento/Customer/Model/Account/Redirect.php +++ b/app/code/Magento/Customer/Model/Account/Redirect.php @@ -9,6 +9,7 @@ use Magento\Customer\Model\Url as CustomerUrl; use Magento\Framework\App\RequestInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; use Magento\Framework\Url\HostChecker; use Magento\Framework\UrlInterface; use Magento\Store\Model\ScopeInterface; @@ -69,6 +70,11 @@ class Redirect */ protected $cookieManager; + /** + * @var CookieMetadataFactory + */ + protected $cookieMetadataFactory; + /** * @var HostChecker */ @@ -88,6 +94,7 @@ class Redirect * @param DecoderInterface $urlDecoder * @param CustomerUrl $customerUrl * @param ResultFactory $resultFactory + * @param CookieMetadataFactory $cookieMetadataFactory * @param HostChecker|null $hostChecker */ public function __construct( @@ -99,6 +106,7 @@ public function __construct( DecoderInterface $urlDecoder, CustomerUrl $customerUrl, ResultFactory $resultFactory, + CookieMetadataFactory $cookieMetadataFactory, HostChecker $hostChecker = null ) { $this->request = $request; @@ -109,6 +117,7 @@ public function __construct( $this->urlDecoder = $urlDecoder; $this->customerUrl = $customerUrl; $this->resultFactory = $resultFactory; + $this->cookieMetadataFactory = $cookieMetadataFactory; $this->hostChecker = $hostChecker ?: ObjectManager::getInstance()->get(HostChecker::class); } @@ -279,7 +288,11 @@ public function getRedirectCookie() */ public function setRedirectCookie($route) { - $this->getCookieManager()->setPublicCookie(self::LOGIN_REDIRECT_URL, $route); + $cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setHttpOnly(true) + ->setDuration(3600) + ->setPath($this->storeManager->getStore()->getStorePath()); + $this->getCookieManager()->setPublicCookie(self::LOGIN_REDIRECT_URL, $route, $cookieMetadata); } /** @@ -289,6 +302,8 @@ public function setRedirectCookie($route) */ public function clearRedirectCookie() { - $this->getCookieManager()->deleteCookie(self::LOGIN_REDIRECT_URL); + $cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() + ->setPath($this->storeManager->getStore()->getStorePath()); + $this->getCookieManager()->deleteCookie(self::LOGIN_REDIRECT_URL, $cookieMetadata); } }