Skip to content

Commit 73335cd

Browse files
committed
magento2-login-as-customer/issues/104: Global refactoring
- Builds fixes
1 parent 1dcf702 commit 73335cd

File tree

11 files changed

+35
-56
lines changed

11 files changed

+35
-56
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
<constraint xsi:type="primary" referenceId="PRIMARY">
1616
<column name="secret"/>
1717
</constraint>
18-
<index referenceId="LOGIN_AS_CUSTOMER_SECRET_CREATED_AT" indexType="btree">
19-
<column name="secret"/>
20-
<column name="created_at"/>
21-
</index>
2218
<index referenceId="LOGIN_AS_CUSTOMER_CREATED_AT" indexType="btree">
2319
<column name="created_at"/>
2420
</index>

app/code/Magento/LoginAsCustomer/etc/db_schema_whitelist.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"created_at": true
88
},
99
"index": {
10-
"LOGIN_AS_CUSTOMER_SECRET_CREATED_AT": true,
1110
"LOGIN_AS_CUSTOMER_CREATED_AT": true
1211
},
1312
"constraint": {

app/code/Magento/LoginAsCustomerApi/Api/Data/AuthenticationDataInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function getCustomerId(): int;
3131
public function getAdminId(): int;
3232

3333
/**
34-
* @inheritdoc
34+
* Get extension attributes
35+
*
36+
* @return AuthenticationDataExtensionInterface|null
3537
*/
3638
public function getExtensionAttributes(): ?AuthenticationDataExtensionInterface;
3739
}

app/code/Magento/LoginAsCustomerLog/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
"magento/module-ui": "*",
1313
"magento/module-user": "*"
1414
},
15+
"suggest": {
16+
"magento/module-login-as-customer": "*"
17+
},
1518
"type": "magento2-module",
1619
"license": [
1720
"OSL-3.0",

app/code/Magento/LoginAsCustomerSales/Plugin/AdminAddCommentOnOrderPlacementPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\LoginAsCustomer\Plugin;
8+
namespace Magento\LoginAsCustomerSales\Plugin;
99

1010
use Magento\Backend\Model\Auth\Session;
1111
use Magento\Sales\Model\Order;

app/code/Magento/LoginAsCustomerSales/Plugin/AuthenticateCustomer.php renamed to app/code/Magento/LoginAsCustomerSales/Plugin/AuthenticateCustomerPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Class AuthenticateCustomer Plugin
1919
*/
20-
class AuthenticateCustomer
20+
class AuthenticateCustomerPlugin
2121
{
2222
/**
2323
* @var CustomerSession

app/code/Magento/LoginAsCustomerSales/Plugin/FrontAddCommentOnOrderPlacementPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\LoginAsCustomer\Plugin;
8+
namespace Magento\LoginAsCustomerSales\Plugin;
99

1010
use Magento\Customer\Model\Session;
1111
use Magento\Sales\Model\Order;

app/code/Magento/LoginAsCustomerSales/composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33
"description": "",
44
"require": {
55
"php": "~7.1.3||~7.2.0||~7.3.0",
6+
"magento/framework": "*",
7+
"magento/module-backend": "*",
68
"magento/module-checkout": "*",
9+
"magento/module-customer": "*",
10+
"magento/module-quote": "*",
711
"magento/module-login-as-customer": "*",
8-
"magento/module-quote": "*"
12+
"magento/module-user": "*"
13+
},
14+
"suggest": {
15+
"magento/sales": "*",
16+
"magento/module-login-as-customer-api": "*"
917
},
1018
"type": "magento2-module",
1119
"license": [

app/code/Magento/LoginAsCustomerSales/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
1010
<type name="Magento\LoginAsCustomerApi\Api\AuthenticateCustomerInterface">
1111
<plugin name="login_as_customer_sales_authenticate_customer"
12-
type="Magento\LoginAsCustomerSales\Plugin\AuthenticateCustomer"/>
12+
type="Magento\LoginAsCustomerSales\Plugin\AuthenticateCustomerPlugin"/>
1313
</type>
1414
</config>

app/code/Magento/LoginAsCustomerUi/Controller/Adminhtml/Login/Login.php

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Magento\Backend\App\Action;
1111
use Magento\Backend\App\Action\Context;
12-
use Magento\Framework\App\RequestInterface;
12+
use Magento\Backend\Model\Auth\Session;
1313
use Magento\Framework\Controller\Result\Redirect;
1414
use Magento\Framework\Controller\ResultFactory;
1515
use Magento\Framework\Controller\ResultInterface;
@@ -18,11 +18,11 @@
1818
use Magento\Customer\Api\CustomerRepositoryInterface;
1919
use Magento\Framework\Exception\LocalizedException;
2020
use Magento\Framework\Exception\NoSuchEntityException;
21-
use Magento\Framework\Message\ManagerInterface;
2221
use Magento\LoginAsCustomerApi\Api\ConfigInterface;
2322
use Magento\LoginAsCustomerApi\Api\Data\AuthenticationDataInterface;
24-
use Magento\LoginAsCustomerApi\Api\Data\AuthenticationDataInterfaceFactor;
23+
use Magento\LoginAsCustomerApi\Api\Data\AuthenticationDataInterfaceFactory;
2524
use Magento\LoginAsCustomerApi\Api\SaveAuthenticationDataInterface;
25+
use Magento\Store\Model\StoreManagerInterface;
2626

2727
/**
2828
* Login as customer action
@@ -40,35 +40,15 @@ class Login extends Action implements HttpGetActionInterface, HttpPostActionInte
4040
const ADMIN_RESOURCE = 'Magento_LoginAsCustomer::login';
4141

4242
/**
43-
* @var ResultFactory
44-
*/
45-
private $resultFactory;
46-
47-
/**
48-
* @var RequestInterface
49-
*/
50-
private $request;
51-
52-
/**
53-
* @var ManagerInterface
54-
*/
55-
private $messageManager;
56-
57-
/**
58-
* @var \Magento\Backend\Model\Auth\Session
43+
* @var Session
5944
*/
6045
private $authSession;
6146

6247
/**
63-
* @var \Magento\Store\Model\StoreManagerInterface
48+
* @var StoreManagerInterface
6449
*/
6550
private $storeManager;
6651

67-
/**
68-
* @var \Magento\Framework\Url
69-
*/
70-
private $url;
71-
7252
/**
7353
* @var CustomerRepositoryInterface
7454
*/
@@ -91,38 +71,26 @@ class Login extends Action implements HttpGetActionInterface, HttpPostActionInte
9171

9272
/**
9373
* @param Context $context
94-
* @param ResultFactory $resultFactory
95-
* @param RequestInterface $request
96-
* @param ManagerInterface $messageManager
97-
* @param \Magento\Backend\Model\Auth\Session $authSession
98-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
99-
* @param \Magento\Framework\Url $url
74+
* @param Session $authSession
75+
* @param StoreManagerInterface $storeManager
10076
* @param CustomerRepositoryInterface $customerRepository
10177
* @param ConfigInterface $config
10278
* @param AuthenticationDataInterfaceFactory $authenticationDataFactory
10379
* @param SaveAuthenticationDataInterface $saveAuthenticationData
10480
*/
10581
public function __construct(
10682
Context $context,
107-
ResultFactory $resultFactory,
108-
RequestInterface $request,
109-
ManagerInterface $messageManager,
110-
\Magento\Backend\Model\Auth\Session $authSession,
111-
\Magento\Store\Model\StoreManagerInterface $storeManager,
112-
\Magento\Framework\Url $url,
83+
Session $authSession,
84+
StoreManagerInterface $storeManager,
11385
CustomerRepositoryInterface $customerRepository,
11486
ConfigInterface $config,
11587
AuthenticationDataInterfaceFactory $authenticationDataFactory,
11688
SaveAuthenticationDataInterface $saveAuthenticationData
11789
) {
11890
parent::__construct($context);
11991

120-
$this->resultFactory = $resultFactory;
121-
$this->request = $request;
122-
$this->messageManager = $messageManager;
12392
$this->authSession = $authSession;
12493
$this->storeManager = $storeManager;
125-
$this->url = $url;
12694
$this->customerRepository = $customerRepository;
12795
$this->config = $config;
12896
$this->authenticationDataFactory = $authenticationDataFactory;
@@ -146,9 +114,9 @@ public function execute(): ResultInterface
146114
return $resultRedirect->setPath('customer/index/index');
147115
}
148116

149-
$customerId = (int)$this->request->getParam('customer_id');
117+
$customerId = (int)$this->_request->getParam('customer_id');
150118
if (!$customerId) {
151-
$customerId = (int)$this->request->getParam('entity_id');
119+
$customerId = (int)$this->_request->getParam('entity_id');
152120
}
153121

154122
try {
@@ -158,7 +126,7 @@ public function execute(): ResultInterface
158126
return $resultRedirect->setPath('customer/index/index');
159127
}
160128

161-
$storeId = $this->request->getParam('store_id');
129+
$storeId = $this->_request->getParam('store_id');
162130
if (empty($storeId) && $this->config->isStoreManualChoiceEnabled()) {
163131
$this->messageManager->addNoticeMessage(__('Please select a Store View to login in.'));
164132
return $resultRedirect->setPath('loginascustomer/login/manual', ['customer_id' => $customerId]);
@@ -195,7 +163,7 @@ private function getLoginProceedRedirectUrl(string $secret, ?int $storeId): stri
195163
$store = $this->storeManager->getStore($storeId);
196164
}
197165

198-
$redirectUrl = $this->url
166+
$redirectUrl = $this->_url
199167
->setScope($store)
200168
->getUrl('loginascustomer/login/index', ['secret' => $secret, '_nosid' => true]);
201169
return $redirectUrl;

0 commit comments

Comments
 (0)