Skip to content

Commit 0bbaf70

Browse files
authored
Merge pull request #148 from ihorvansach/magento2-login-as-customer/issues/102
magento2-login-as-customer/issues/102
2 parents 8694e0b + 185772d commit 0bbaf70

File tree

1 file changed

+7
-3
lines changed
  • app/code/Magento/LoginAsCustomerUi/Controller/Adminhtml/Login

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3636
*/
37-
class Login extends Action implements HttpGetActionInterface, HttpPostActionInterface
37+
class Login extends Action implements HttpGetActionInterface
3838
{
3939
/**
4040
* Authorization level of a basic admin session
@@ -140,7 +140,7 @@ public function execute(): ResultInterface
140140
}
141141

142142
try {
143-
$this->customerRepository->getById($customerId);
143+
$customer = $this->customerRepository->getById($customerId);
144144
} catch (NoSuchEntityException $e) {
145145
$this->messageManager->addErrorMessage(__('Customer with this ID are no longer exist.'));
146146
return $resultRedirect->setPath('customer/index/index');
@@ -170,6 +170,10 @@ public function execute(): ResultInterface
170170
$this->deleteExpiredAuthenticationData->execute($userId);
171171
$secret = $this->saveAuthenticationData->execute($authenticationData);
172172

173+
if (empty($storeId)) {
174+
$storeId = (int)$customer->getStoreId();
175+
}
176+
173177
$redirectUrl = $this->getLoginProceedRedirectUrl($secret, $storeId);
174178
$resultRedirect->setUrl($redirectUrl);
175179
return $resultRedirect;
@@ -185,7 +189,7 @@ public function execute(): ResultInterface
185189
*/
186190
private function getLoginProceedRedirectUrl(string $secret, ?int $storeId): string
187191
{
188-
if (null === $storeId) {
192+
if (empty($storeId)) {
189193
$store = $this->storeManager->getDefaultStoreView();
190194
} else {
191195
$store = $this->storeManager->getStore($storeId);

0 commit comments

Comments
 (0)