@@ -423,6 +423,7 @@ class AccountManagement implements AccountManagementInterface
423
423
* @param GetCustomerByToken|null $getByToken
424
424
* @param AllowedCountries|null $allowedCountriesReader
425
425
* @param SessionCleanerInterface|null $sessionCleaner
426
+ * @param AuthorizationInterface|null $authorization
426
427
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
427
428
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
428
429
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -463,7 +464,8 @@ public function __construct(
463
464
AddressRegistry $ addressRegistry = null ,
464
465
GetCustomerByToken $ getByToken = null ,
465
466
AllowedCountries $ allowedCountriesReader = null ,
466
- SessionCleanerInterface $ sessionCleaner = null
467
+ SessionCleanerInterface $ sessionCleaner = null ,
468
+ AuthorizationInterface $ authorization = null
467
469
) {
468
470
$ this ->customerFactory = $ customerFactory ;
469
471
$ this ->eventManager = $ eventManager ;
@@ -503,6 +505,7 @@ public function __construct(
503
505
$ this ->allowedCountriesReader = $ allowedCountriesReader
504
506
?: $ objectManager ->get (AllowedCountries::class);
505
507
$ this ->sessionCleaner = $ sessionCleaner ?? $ objectManager ->get (SessionCleanerInterface::class);
508
+ $ this ->authorization = $ authorization ?? $ objectManager ->get (AuthorizationInterface::class);
506
509
}
507
510
508
511
/**
@@ -521,22 +524,6 @@ private function getAuthentication()
521
524
}
522
525
}
523
526
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
-
540
527
/**
541
528
* @inheritdoc
542
529
*/
@@ -862,9 +849,8 @@ public function getConfirmationStatus($customerId)
862
849
*/
863
850
public function createAccount (CustomerInterface $ customer , $ password = null , $ redirectUrl = '' )
864
851
{
865
- $ auth = $ this ->getAuthorization ();
866
852
$ groupId = $ customer ->getGroupId ();
867
- if (isset ($ groupId ) && !$ auth ->isAllowed (self ::ADMIN_RESOURCE )) {
853
+ if (isset ($ groupId ) && !$ this -> authorization ->isAllowed (self ::ADMIN_RESOURCE )) {
868
854
$ customer ->setGroupId (null );
869
855
}
870
856
0 commit comments