Skip to content

Commit 65be36e

Browse files
author
Mark Berube
committed
MC-40099: Changing groupId functionality on createAccount()
1 parent 84aba1a commit 65be36e

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ class AccountManagement implements AccountManagementInterface
423423
* @param GetCustomerByToken|null $getByToken
424424
* @param AllowedCountries|null $allowedCountriesReader
425425
* @param SessionCleanerInterface|null $sessionCleaner
426-
* @param AuthorizationInterface|null $authorization
427426
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
428427
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
429428
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -464,8 +463,7 @@ public function __construct(
464463
AddressRegistry $addressRegistry = null,
465464
GetCustomerByToken $getByToken = null,
466465
AllowedCountries $allowedCountriesReader = null,
467-
SessionCleanerInterface $sessionCleaner = null,
468-
AuthorizationInterface $authorization = null
466+
SessionCleanerInterface $sessionCleaner = null
469467
) {
470468
$this->customerFactory = $customerFactory;
471469
$this->eventManager = $eventManager;
@@ -505,7 +503,6 @@ public function __construct(
505503
$this->allowedCountriesReader = $allowedCountriesReader
506504
?: $objectManager->get(AllowedCountries::class);
507505
$this->sessionCleaner = $sessionCleaner ?? $objectManager->get(SessionCleanerInterface::class);
508-
$this->authorization = $authorization ?? $objectManager->get(AuthorizationInterface::class);
509506
}
510507

511508
/**
@@ -524,6 +521,22 @@ private function getAuthentication()
524521
}
525522
}
526523

524+
/**
525+
* Get authorization
526+
*
527+
* @return AuthorizationInterface
528+
*/
529+
private function getAuthorization()
530+
{
531+
if (!($this->authorization instanceof AuthorizationInterface)) {
532+
$this->authorization = \Magento\Framework\App\ObjectManager::getInstance()->get(
533+
AuthorizationInterface::class
534+
);
535+
}
536+
537+
return $this->authorization;
538+
}
539+
527540
/**
528541
* @inheritdoc
529542
*/
@@ -849,8 +862,9 @@ public function getConfirmationStatus($customerId)
849862
*/
850863
public function createAccount(CustomerInterface $customer, $password = null, $redirectUrl = '')
851864
{
865+
$auth = $this->getAuthorization();
852866
$groupId = $customer->getGroupId();
853-
if (isset($groupId) && !$this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
867+
if (isset($groupId) && !$auth->isAllowed(self::ADMIN_RESOURCE)) {
854868
$customer->setGroupId(null);
855869
}
856870

0 commit comments

Comments
 (0)