-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from magento-commerce/magento2-login-as-custom…
…er/issues/29 magento2-login-as-customer/issues/29: Destroy impersonated customer sessions on admin logout.
- Loading branch information
Showing
15 changed files
with
191 additions
and
100 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
app/code/Magento/LoginAsCustomer/Cron/DeleteExpiredAuthenticationData.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/code/Magento/LoginAsCustomerApi/Api/IsLoginAsCustomerSessionActiveInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\LoginAsCustomerApi\Api; | ||
|
||
/** | ||
* Check if Login as Customer session is still active. | ||
* | ||
* @api | ||
*/ | ||
interface IsLoginAsCustomerSessionActiveInterface | ||
{ | ||
/** | ||
* Check if Login as Customer session is still active. | ||
* | ||
* @param int $customerId | ||
* @param int $userId | ||
* @return bool | ||
*/ | ||
public function execute(int $customerId, int $userId): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/code/Magento/LoginAsCustomerUi/Plugin/AdminLogoutPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\LoginAsCustomerUi\Plugin; | ||
|
||
use Magento\Backend\Model\Auth; | ||
use Magento\LoginAsCustomerApi\Api\ConfigInterface; | ||
use Magento\LoginAsCustomerApi\Api\DeleteExpiredAuthenticationDataInterface; | ||
|
||
/** | ||
* Delete all Login as Customer sessions for logging out admin. | ||
*/ | ||
class AdminLogoutPlugin | ||
{ | ||
/** | ||
* @var ConfigInterface | ||
*/ | ||
private $config; | ||
|
||
/** | ||
* @var DeleteExpiredAuthenticationDataInterface | ||
*/ | ||
private $deleteExpiredAuthenticationData; | ||
|
||
/** | ||
* @param ConfigInterface $config | ||
* @param DeleteExpiredAuthenticationDataInterface $deleteExpiredAuthenticationData | ||
*/ | ||
public function __construct( | ||
ConfigInterface $config, | ||
DeleteExpiredAuthenticationDataInterface $deleteExpiredAuthenticationData | ||
) { | ||
$this->config = $config; | ||
$this->deleteExpiredAuthenticationData = $deleteExpiredAuthenticationData; | ||
} | ||
|
||
/** | ||
* Delete all Login as Customer sessions for logging out admin. | ||
* | ||
* @param Auth $subject | ||
*/ | ||
public function beforeLogout(Auth $subject): void | ||
{ | ||
if ($this->config->isEnabled()) { | ||
$userId = (int)$subject->getUser()->getId(); | ||
$this->deleteExpiredAuthenticationData->execute($userId); | ||
} | ||
} | ||
} |
Oops, something went wrong.