Skip to content

Commit e1b12e9

Browse files
author
Anna Bukatar
committed
ACP2E-1763: Issue with Cart when logged in as customer from admin
1 parent c7464fe commit e1b12e9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Persistent\Model\Plugin;
9+
10+
use Magento\LoginAsCustomerApi\Api\AuthenticateCustomerBySecretInterface;
11+
use Magento\Persistent\Helper\Session as PersistentSession;
12+
13+
class LoginAsCustomerCleanUp
14+
{
15+
/**
16+
* @var PersistentSession
17+
*/
18+
private $persistentSession;
19+
20+
/**
21+
* @param PersistentSession $persistentSession
22+
*/
23+
public function __construct(PersistentSession $persistentSession)
24+
{
25+
$this->persistentSession = $persistentSession;
26+
}
27+
28+
/**
29+
* @param AuthenticateCustomerBySecretInterface $subject
30+
* @param string $secret
31+
* @return string
32+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
*/
34+
public function beforeExecute(AuthenticateCustomerBySecretInterface $subject, string $secret)
35+
{
36+
if ($this->persistentSession->isPersistent()) {
37+
$this->persistentSession->getSession()->removePersistentCookie();
38+
}
39+
return $secret;
40+
}
41+
}

app/code/Magento/Persistent/etc/frontend/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@
5757
<argument name="shippingAssignmentProcessor" xsi:type="object">Magento\Quote\Model\Quote\ShippingAssignment\ShippingAssignmentProcessor\Proxy</argument>
5858
</arguments>
5959
</type>
60+
<type name="Magento\LoginAsCustomerApi\Api\AuthenticateCustomerBySecretInterface">
61+
<plugin name="login_as_customer_cleanup" type="Magento\Persistent\Model\Plugin\LoginAsCustomerCleanUp" />
62+
</type>
6063
</config>

0 commit comments

Comments
 (0)