Skip to content

Commit 3b77de5

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

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

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

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ class AccountManagement implements AccountManagementInterface
423423
* @param GetCustomerByToken|null $getByToken
424424
* @param AllowedCountries|null $allowedCountriesReader
425425
* @param SessionCleanerInterface|null $sessionCleaner
426+
* @param AuthorizationInterface|null $authorization
426427
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
427428
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
428429
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -463,7 +464,8 @@ public function __construct(
463464
AddressRegistry $addressRegistry = null,
464465
GetCustomerByToken $getByToken = null,
465466
AllowedCountries $allowedCountriesReader = null,
466-
SessionCleanerInterface $sessionCleaner = null
467+
SessionCleanerInterface $sessionCleaner = null,
468+
AuthorizationInterface $authorization = null
467469
) {
468470
$this->customerFactory = $customerFactory;
469471
$this->eventManager = $eventManager;
@@ -503,6 +505,7 @@ public function __construct(
503505
$this->allowedCountriesReader = $allowedCountriesReader
504506
?: $objectManager->get(AllowedCountries::class);
505507
$this->sessionCleaner = $sessionCleaner ?? $objectManager->get(SessionCleanerInterface::class);
508+
$this->authorization = $authorization ?? $objectManager->get(AuthorizationInterface::class);
506509
}
507510

508511
/**
@@ -521,22 +524,6 @@ private function getAuthentication()
521524
}
522525
}
523526

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-
540527
/**
541528
* @inheritdoc
542529
*/
@@ -862,9 +849,8 @@ public function getConfirmationStatus($customerId)
862849
*/
863850
public function createAccount(CustomerInterface $customer, $password = null, $redirectUrl = '')
864851
{
865-
$auth = $this->getAuthorization();
866852
$groupId = $customer->getGroupId();
867-
if (isset($groupId) && !$auth->isAllowed(self::ADMIN_RESOURCE)) {
853+
if (isset($groupId) && !$this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
868854
$customer->setGroupId(null);
869855
}
870856

dev/tests/integration/testsuite/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@
55
*/
66
namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View\Tab;
77

8+
use Magento\Framework\App\Request\Http as HttpRequest;
9+
10+
/**
11+
* Testing Info tab
12+
*
13+
* @magentoAppArea adminhtml
14+
*/
815
class InfoTest extends \Magento\TestFramework\TestCase\AbstractBackendController
916
{
1017
/**
1118
* @magentoDataFixture Magento/Customer/_files/customer.php
1219
* @magentoDataFixture Magento/Paypal/_files/billing_agreement.php
20+
* @magentoAppIsolation enabled
1321
*/
1422
public function testCustomerGridAction()
1523
{

0 commit comments

Comments
 (0)