Skip to content

Commit 27b1133

Browse files
magento2-login-as-customer/issues/136: Login as Customer Log is available when Login as Customer is disabled.
1 parent 6b6f428 commit 27b1133

File tree

2 files changed

+34
-1
lines changed
  • app/code/Magento/LoginAsCustomerLog

2 files changed

+34
-1
lines changed

app/code/Magento/LoginAsCustomerLog/Controller/Adminhtml/Log/Index.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
namespace Magento\LoginAsCustomerLog\Controller\Adminhtml\Log;
99

1010
use Magento\Backend\App\Action;
11+
use Magento\Backend\App\Action\Context;
1112
use Magento\Framework\App\Action\HttpGetActionInterface;
13+
use Magento\Framework\App\RequestInterface;
1214
use Magento\Framework\Controller\ResultFactory;
1315
use Magento\Framework\Controller\ResultInterface;
16+
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
1417

1518
/**
1619
* Login As Customer log grid controller.
@@ -19,6 +22,35 @@ class Index extends Action implements HttpGetActionInterface
1922
{
2023
const ADMIN_RESOURCE = 'Magento_LoginAsCustomerLog::login_log';
2124

25+
/**
26+
* @var ConfigInterface
27+
*/
28+
private $config;
29+
30+
/**.
31+
* @param Context $context
32+
* @param ConfigInterface $config
33+
*/
34+
public function __construct(
35+
Context $context,
36+
ConfigInterface $config
37+
) {
38+
parent::__construct($context);
39+
$this->config = $config;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function dispatch(RequestInterface $request)
46+
{
47+
if (!$this->config->isEnabled() && ($request->getActionName() !== 'noroute')) {
48+
$this->_forward('noroute');
49+
}
50+
51+
return parent::dispatch($request);
52+
}
53+
2254
/**
2355
* @inheritdoc
2456
*/

app/code/Magento/LoginAsCustomerLog/etc/adminhtml/menu.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
parent="Magento_Customer::customer"
1515
sortOrder="40"
1616
resource="Magento_LoginAsCustomerLog::login_log"
17-
action="loginascustomer_log/log/index"/>
17+
action="loginascustomer_log/log/index"
18+
dependsOnConfig="login_as_customer/general/enabled"/>
1819
</menu>
1920
</config>

0 commit comments

Comments
 (0)