Skip to content

Commit 22e91fb

Browse files
Merge remote-tracking branch '38462/patch-3' into commpr-21755-2209
2 parents c9b0983 + 6002a52 commit 22e91fb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ public function createAccountWithPasswordHash(CustomerInterface $customer, $hash
967967
}
968968
$this->customerRegistry->remove($customer->getId());
969969
} catch (InputException $e) {
970-
$this->customerRepository->delete($customer);
970+
$this->deleteCustomerInSecureArea($customer);
971+
971972
throw $e;
972973
}
973974
$customer = $this->customerRepository->getById($customer->getId());
@@ -1678,4 +1679,23 @@ private function isAddressAllowedForWebsite(AddressInterface $address, $storeId)
16781679

16791680
return in_array($address->getCountryId(), $allowedCountries);
16801681
}
1682+
1683+
/**
1684+
* Set isSecureArea to true, then delete the customer and revert isSecureArea to original value
1685+
*
1686+
* @param CustomerInterface $customer
1687+
* @return void
1688+
* @throws LocalizedException
1689+
*/
1690+
private function deleteCustomerInSecureArea(CustomerInterface $customer): void
1691+
{
1692+
$originalValue = $this->registry->registry('isSecureArea');
1693+
$this->registry->unregister('isSecureArea');
1694+
$this->registry->register('isSecureArea', true);
1695+
1696+
$this->customerRepository->delete($customer);
1697+
1698+
$this->registry->unregister('isSecureArea');
1699+
$this->registry->register('isSecureArea', $originalValue);
1700+
}
16811701
}

0 commit comments

Comments
 (0)