Skip to content

Commit 185772d

Browse files
committed
Admin user is logged into the default website if customer registered on second website [Login as Customer]
1 parent 6b6f428 commit 185772d

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');
@@ -167,6 +167,10 @@ public function execute(): ResultInterface
167167
$this->deleteExpiredAuthenticationData->execute($userId);
168168
$secret = $this->saveAuthenticationData->execute($authenticationData);
169169

170+
if (empty($storeId)) {
171+
$storeId = (int)$customer->getStoreId();
172+
}
173+
170174
$redirectUrl = $this->getLoginProceedRedirectUrl($secret, $storeId);
171175
$resultRedirect->setUrl($redirectUrl);
172176
return $resultRedirect;
@@ -182,7 +186,7 @@ public function execute(): ResultInterface
182186
*/
183187
private function getLoginProceedRedirectUrl(string $secret, ?int $storeId): string
184188
{
185-
if (null === $storeId) {
189+
if (empty($storeId)) {
186190
$store = $this->storeManager->getDefaultStoreView();
187191
} else {
188192
$store = $this->storeManager->getStore($storeId);

0 commit comments

Comments
 (0)