Skip to content

Commit 0a71a59

Browse files
cia-2.4.8-beta1-develop-bugfix-05202024: resolve conflict
2 parents a98f366 + 6ded7a7 commit 0a71a59

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Quote\Plugin;
10+
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Framework\Webapi\Rest\Request as RestRequest;
13+
use Magento\Quote\Api\CartRepositoryInterface;
14+
use Magento\Quote\Api\Data\CartInterface;
15+
use Magento\Sales\Api\OrderRepositoryInterface;
16+
17+
/**
18+
* Validate order id from request param
19+
*/
20+
class ValidateQuoteOrigOrder
21+
{
22+
/**
23+
* @var OrderRepositoryInterface
24+
*/
25+
private $orderRepository;
26+
27+
/**
28+
* @var RestRequest $request
29+
*/
30+
private $request;
31+
32+
/**
33+
* @param RestRequest $request
34+
* @param OrderRepositoryInterface $orderRepository
35+
*/
36+
public function __construct(RestRequest $request, OrderRepositoryInterface $orderRepository)
37+
{
38+
$this->request = $request;
39+
$this->orderRepository = $orderRepository;
40+
}
41+
42+
/**
43+
* Validate the user authorization to order
44+
*
45+
* @param CartRepositoryInterface $cartRepository
46+
* @param CartInterface $quote
47+
* @return void
48+
* @throws NoSuchEntityException
49+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
50+
*/
51+
public function beforeSave(
52+
CartRepositoryInterface $cartRepository,
53+
CartInterface $quote
54+
): void {
55+
$params = $this->request->getBodyParams();
56+
if (!empty($params) && isset($params['quote']['orig_order_id'])) {
57+
$orderId = $params['quote']['orig_order_id'];
58+
$order = $this->orderRepository->get($orderId);
59+
$orderCustomer = (int)$order->getCustomerId();
60+
if ($quote->getCustomerId() !== $orderCustomer) {
61+
throw new NoSuchEntityException(__('Please check input parameters.'));
62+
}
63+
}
64+
}
65+
}

app/code/Magento/Quote/etc/webapi_rest/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
<type name="Magento\Quote\Model\Quote">
2020
<plugin name="updateQuoteStoreId" type="Magento\Quote\Model\Quote\Plugin\UpdateQuoteStoreId" />
2121
</type>
22+
<type name="Magento\Quote\Api\CartRepositoryInterface">
23+
<plugin name="quoteValidateOrderId" type="Magento\Quote\Plugin\ValidateQuoteOrigOrder"/>
24+
</type>
2225
</config>

app/code/Magento/Quote/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ Carts,Carts
7474
"Please select a valid rate limit period in seconds: %1.","Please select a valid rate limit period in seconds: %1."
7575
"Identity type not found","Identity type not found"
7676
"Invalid order backpressure limit config","Invalid order backpressure limit config"
77+
"Please check input parameters.","Please check input parameters."

0 commit comments

Comments
 (0)