|
9 | 9 |
|
10 | 10 | use Magento\Customer\Api\Data\AddressInterface;
|
11 | 11 | use Magento\CustomerGraphQl\Model\Customer\CheckCustomerAccount;
|
| 12 | +use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; |
12 | 13 | use Magento\Framework\GraphQl\Exception\GraphQlInputException;
|
13 | 14 | use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
|
14 | 15 | use Magento\Quote\Api\Data\CartInterface;
|
@@ -61,6 +62,16 @@ public function __construct(
|
61 | 62 |
|
62 | 63 | /**
|
63 | 64 | * @inheritdoc
|
| 65 | + * @param ContextInterface $context |
| 66 | + * @param CartInterface $cart |
| 67 | + * @param array $billingAddress |
| 68 | + * @throws GraphQlAuthorizationException |
| 69 | + * @throws GraphQlInputException |
| 70 | + * @throws \Magento\Framework\Exception\InputException |
| 71 | + * @throws \Magento\Framework\Exception\LocalizedException |
| 72 | + * @throws \Magento\Framework\Exception\NoSuchEntityException |
| 73 | + * @throws \Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException |
| 74 | + * @throws \Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException |
64 | 75 | */
|
65 | 76 | public function execute(ContextInterface $context, CartInterface $cart, array $billingAddress): void
|
66 | 77 | {
|
@@ -91,6 +102,16 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
|
91 | 102 |
|
92 | 103 | /** @var AddressInterface $customerAddress */
|
93 | 104 | $customerAddress = $this->addressRepository->getById($customerAddressId);
|
| 105 | + |
| 106 | + if ((int)$customerAddress->getCustomerId() !== $context->getUserId()) { |
| 107 | + throw new GraphQlAuthorizationException( |
| 108 | + __( |
| 109 | + 'The current user cannot use address with ID "%customer_address_id"', |
| 110 | + ['customer_address_id' => $customerAddressId] |
| 111 | + ) |
| 112 | + ); |
| 113 | + } |
| 114 | + |
94 | 115 | $billingAddress = $this->addressModel->importCustomerAddressData($customerAddress);
|
95 | 116 | }
|
96 | 117 |
|
|
0 commit comments