Skip to content

Commit d9c02ed

Browse files
magento/magento2-login-as-customer#144: "Login as Customer" functionality should be enabled by default.
1 parent 625e57e commit d9c02ed

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

app/code/Magento/LoginAsCustomer/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<default>
1111
<login_as_customer>
1212
<general>
13-
<enabled>0</enabled>
13+
<enabled>1</enabled>
1414
<store_view_manual_choice_enabled>0</store_view_manual_choice_enabled>
1515
<authentication_data_expiration_time>60</authentication_data_expiration_time>
1616
</general>

app/code/Magento/LoginAsCustomerFrontendUi/ViewModel/Configuration.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
namespace Magento\LoginAsCustomerFrontendUi\ViewModel;
99

1010
use Magento\Customer\Model\Context;
11+
use Magento\Framework\App\Http\Context as HttpContext;
1112
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
13+
use Magento\LoginAsCustomerApi\Api\GetLoggedAsCustomerAdminIdInterface;
1214

1315
/**
1416
* View model to get extension configuration in the template
@@ -21,20 +23,28 @@ class Configuration implements \Magento\Framework\View\Element\Block\ArgumentInt
2123
private $config;
2224

2325
/**
24-
* @var \Magento\Framework\App\Http\Context
26+
* @var HttpContext
2527
*/
2628
private $httpContext;
2729

30+
/**
31+
* @var GetLoggedAsCustomerAdminIdInterface
32+
*/
33+
private $getLoggedAsCustomerAdminId;
34+
2835
/**
2936
* @param ConfigInterface $config
30-
* @param \Magento\Framework\App\Http\Context $httpContext
37+
* @param HttpContext $httpContext
38+
* @param GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
3139
*/
3240
public function __construct(
3341
ConfigInterface $config,
34-
\Magento\Framework\App\Http\Context $httpContext
42+
HttpContext $httpContext,
43+
GetLoggedAsCustomerAdminIdInterface $getLoggedAsCustomerAdminId
3544
) {
3645
$this->config = $config;
3746
$this->httpContext = $httpContext;
47+
$this->getLoggedAsCustomerAdminId = $getLoggedAsCustomerAdminId;
3848
}
3949

4050
/**
@@ -44,7 +54,7 @@ public function __construct(
4454
*/
4555
public function isEnabled(): bool
4656
{
47-
return $this->config->isEnabled() && $this->isLoggedIn();
57+
return $this->config->isEnabled() && $this->isLoggedIn() && $this->getLoggedAsCustomerAdminId->execute();
4858
}
4959

5060
/**

0 commit comments

Comments
 (0)