Skip to content

Commit e6709c4

Browse files
committed
Merge branch '2.3.7-develop' of github.com:magento/magento2ce into cia-2.3.7-2102021-CE
2 parents 378c074 + 4058363 commit e6709c4

File tree

3 files changed

+385
-52
lines changed

3 files changed

+385
-52
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
use Magento\Store\Model\ScopeInterface;
5656
use Magento\Store\Model\StoreManagerInterface;
5757
use Psr\Log\LoggerInterface as PsrLogger;
58+
use Magento\Framework\AuthorizationInterface;
5859

5960
/**
6061
* Handle various customer account actions
@@ -205,6 +206,13 @@ class AccountManagement implements AccountManagementInterface
205206
*/
206207
const MIN_PASSWORD_LENGTH = 6;
207208

209+
/**
210+
* Authorization level of a basic admin session
211+
*
212+
* @see _isAllowed()
213+
*/
214+
const ADMIN_RESOURCE = 'Magento_Customer::manage';
215+
208216
/**
209217
* @var CustomerFactory
210218
*/
@@ -375,6 +383,11 @@ class AccountManagement implements AccountManagementInterface
375383
*/
376384
private $sessionCleaner;
377385

386+
/**
387+
* @var AuthorizationInterface
388+
*/
389+
protected $authorization;
390+
378391
/**
379392
* @param CustomerFactory $customerFactory
380393
* @param ManagerInterface $eventManager
@@ -410,6 +423,7 @@ class AccountManagement implements AccountManagementInterface
410423
* @param GetCustomerByToken|null $getByToken
411424
* @param AllowedCountries|null $allowedCountriesReader
412425
* @param SessionCleanerInterface|null $sessionCleaner
426+
* @param AuthorizationInterface|null $authorization
413427
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
414428
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
415429
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -450,7 +464,8 @@ public function __construct(
450464
AddressRegistry $addressRegistry = null,
451465
GetCustomerByToken $getByToken = null,
452466
AllowedCountries $allowedCountriesReader = null,
453-
SessionCleanerInterface $sessionCleaner = null
467+
SessionCleanerInterface $sessionCleaner = null,
468+
AuthorizationInterface $authorization = null
454469
) {
455470
$this->customerFactory = $customerFactory;
456471
$this->eventManager = $eventManager;
@@ -490,6 +505,7 @@ public function __construct(
490505
$this->allowedCountriesReader = $allowedCountriesReader
491506
?: $objectManager->get(AllowedCountries::class);
492507
$this->sessionCleaner = $sessionCleaner ?? $objectManager->get(SessionCleanerInterface::class);
508+
$this->authorization = $authorization ?? $objectManager->get(AuthorizationInterface::class);
493509
}
494510

495511
/**
@@ -833,6 +849,11 @@ public function getConfirmationStatus($customerId)
833849
*/
834850
public function createAccount(CustomerInterface $customer, $password = null, $redirectUrl = '')
835851
{
852+
$groupId = $customer->getGroupId();
853+
if (isset($groupId) && !$this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
854+
$customer->setGroupId(null);
855+
}
856+
836857
if ($password !== null) {
837858
$this->checkPasswordStrength($password);
838859
$customerEmail = $customer->getEmail();

0 commit comments

Comments
 (0)