Skip to content

Commit

Permalink
Fix for the issue #24547
Browse files Browse the repository at this point in the history
  • Loading branch information
sashas777 committed Sep 15, 2019
1 parent 5ee35e5 commit a15f335
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions app/code/Magento/Customer/Model/Account/Redirect.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,6 +70,11 @@ class Redirect
*/
protected $cookieManager;

/**
* @var CookieMetadataFactory
*/
protected $cookieMetadataFactory;

/**
* @var HostChecker
*/
Expand All @@ -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(
Expand All @@ -99,6 +106,7 @@ public function __construct(
DecoderInterface $urlDecoder,
CustomerUrl $customerUrl,
ResultFactory $resultFactory,
CookieMetadataFactory $cookieMetadataFactory,
HostChecker $hostChecker = null
) {
$this->request = $request;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}
}

0 comments on commit a15f335

Please sign in to comment.