Skip to content

Commit 3e100dd

Browse files
AnujNehraAnujNehra
authored andcommitted
ACP2E-1776: Creating customer(-s) via Async REST API ignores group_id
1 parent 2b3c704 commit 3e100dd

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

app/code/Magento/AsynchronousOperations/Model/MassSchedule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Psr\Log\LoggerInterface;
2222

2323
/**
24-
* Class MassSchedule used for adding multiple entities as Operations to Bulk Management with the status tracking
24+
* Class MassSchedulePlugin used for adding multiple entities as Operations to Bulk Management with the status tracking
2525
*
2626
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) Suppressed without refactoring to not introduce BiC
2727
*/

app/code/Magento/Customer/Plugin/AccountManagementApi.php renamed to app/code/Magento/Customer/Plugin/ValidateSyncCustomer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
use Magento\Framework\App\ObjectManager;
1313
use Magento\Framework\AuthorizationInterface;
1414
use Magento\Framework\Exception\AuthorizationException;
15-
use Magento\Customer\Model\AccountManagementApi as SubjectAccountManagementApi;
15+
use Magento\Customer\Model\AccountManagementApi;
1616

1717
/**
18-
* Plugin to validate anonymous request for synchronous operations contains group id.
18+
* Plugin to validate anonymous request for synchronous operations containing group id.
1919
*/
20-
class AccountManagementApi
20+
class ValidateSyncCustomer
2121
{
2222
/**
2323
* Authorization level of a basic admin session
@@ -45,14 +45,14 @@ public function __construct(
4545
/**
4646
* Validate groupId for anonymous request
4747
*
48-
* @param SubjectAccountManagementApi $subjectAccountManagementApi
48+
* @param AccountManagementApi $accountManagementApi
4949
* @param CustomerInterface $customer
5050
* @return void
5151
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5252
* @throws AuthorizationException
5353
*/
5454
public function beforeCreateAccount(
55-
SubjectAccountManagementApi $subjectAccountManagementApi,
55+
AccountManagementApi $accountManagementApi,
5656
CustomerInterface $customer
5757
): void {
5858
$groupId = $customer->getGroupId();

app/code/Magento/Customer/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@
586586
</arguments>
587587
</type>
588588
<type name="Magento\Customer\Model\AccountManagementApi">
589-
<plugin name="anonymousRequestForSynchronousOperations"
590-
type="Magento\Customer\Plugin\AccountManagementApi"
589+
<plugin name="validateSyncAnonymousRequestForCustomer"
590+
type="Magento\Customer\Plugin\ValidateSyncCustomer"
591591
/>
592592
</type>
593593
</config>

app/code/Magento/WebapiAsync/Plugin/AsynchronousOperations/MassSchedule.php renamed to app/code/Magento/WebapiAsync/Plugin/AsynchronousOperations/ValidateAsyncCustomer.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88

99
namespace Magento\WebapiAsync\Plugin\AsynchronousOperations;
1010

11-
use Magento\Customer\Api\Data\CustomerInterface;
1211
use Magento\Framework\App\ObjectManager;
1312
use Magento\Framework\AuthorizationInterface;
1413
use Magento\Framework\Exception\AuthorizationException;
15-
use Magento\AsynchronousOperations\Model\MassSchedule as SubjectMassSchedule;
14+
use Magento\AsynchronousOperations\Model\MassSchedule;
1615

1716
/**
18-
* Plugin to validate anonymous request for asynchronous operations contains group id.
17+
* Plugin to validate anonymous request for asynchronous operations containing group id.
1918
*/
20-
class MassSchedule
19+
class ValidateAsyncCustomer
2120
{
2221
/**
2322
* Authorization level of a basic admin session
@@ -45,21 +44,21 @@ public function __construct(
4544
/**
4645
* Validate groupId for anonymous request
4746
*
48-
* @param SubjectMassSchedule $subjectMassSchedule
47+
* @param MassSchedule $massSchedule
4948
* @param string $topic
5049
* @param array $entitiesArray
5150
* @return void
5251
* @throws AuthorizationException
5352
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5453
*/
5554
public function beforePublishMass(
56-
SubjectMassSchedule $subjectMassSchedule,
55+
MassSchedule $massSchedule,
5756
string $topic,
5857
array $entitiesArray
5958
): void {
6059
foreach ($entitiesArray as $entityParams) {
6160
foreach ($entityParams as $customer) {
62-
if ($customer instanceof CustomerInterface) {
61+
if (is_object($customer)) {
6362
$groupId = $customer->getGroupId();
6463
if (isset($groupId) && !$this->authorization->isAllowed(self::ADMIN_RESOURCE)) {
6564
$params = ['resources' => self::ADMIN_RESOURCE];

app/code/Magento/WebapiAsync/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"magento/framework": "*",
1010
"magento/module-webapi": "*",
1111
"magento/module-asynchronous-operations": "*",
12-
"magento/module-store": "*",
13-
"magento/module-customer": "*"
12+
"magento/module-store": "*"
1413
},
1514
"suggest": {
1615
"magento/module-user": "*",

app/code/Magento/WebapiAsync/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
/>
7676
</type>
7777
<type name="Magento\AsynchronousOperations\Model\MassSchedule">
78-
<plugin name="anonymousRequestForAsynchronousOperationsMassSchedule"
79-
type="Magento\WebapiAsync\Plugin\AsynchronousOperations\MassSchedule"
78+
<plugin name="validateAsyncAnonymousRequestForCustomer"
79+
type="Magento\WebapiAsync\Plugin\AsynchronousOperations\ValidateAsyncCustomer"
8080
/>
8181
</type>
8282
</config>

0 commit comments

Comments
 (0)