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