Skip to content

Commit

Permalink
Fix the issue with reset password when customer has address from not …
Browse files Browse the repository at this point in the history
…allowed country
  • Loading branch information
dmytro-ch committed Sep 21, 2018
1 parent 8fd89cf commit 030b223
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ class AccountManagement implements AccountManagementInterface
*/
private $accountConfirmation;

/**
* @var AddressRegistry
*/
private $addressRegistry;

/**
* @param CustomerFactory $customerFactory
* @param ManagerInterface $eventManager
Expand Down Expand Up @@ -356,6 +361,7 @@ class AccountManagement implements AccountManagementInterface
* @param SessionManagerInterface|null $sessionManager
* @param SaveHandlerInterface|null $saveHandler
* @param CollectionFactory|null $visitorCollectionFactory
* @param AddressRegistry|null $addressRegistry
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand Down Expand Up @@ -387,7 +393,8 @@ public function __construct(
AccountConfirmation $accountConfirmation = null,
SessionManagerInterface $sessionManager = null,
SaveHandlerInterface $saveHandler = null,
CollectionFactory $visitorCollectionFactory = null
CollectionFactory $visitorCollectionFactory = null,
AddressRegistry $addressRegistry
) {
$this->customerFactory = $customerFactory;
$this->eventManager = $eventManager;
Expand Down Expand Up @@ -423,6 +430,8 @@ public function __construct(
?: ObjectManager::getInstance()->get(SaveHandlerInterface::class);
$this->visitorCollectionFactory = $visitorCollectionFactory
?: ObjectManager::getInstance()->get(CollectionFactory::class);
$this->addressRegistry = $addressRegistry
?: ObjectManager::getInstance()->get(AddressRegistry::class);
}

/**
Expand Down Expand Up @@ -568,6 +577,12 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
// load customer by email
$customer = $this->customerRepository->get($email, $websiteId);

foreach ($customer->getAddresses() as $address) {
// No need to validate customer address while saving customer reset password token
$addressModel = $this->addressRegistry->retrieve($address->getId());
$addressModel->setShouldIgnoreValidation(true);
}

$newPasswordToken = $this->mathRandom->getUniqueHash();
$this->changeResetPasswordLinkToken($customer, $newPasswordToken);

Expand Down

0 comments on commit 030b223

Please sign in to comment.