Skip to content

Commit 7fc5494

Browse files
committed
magento/graphql-ce#486: Add customer account validation in Quote operations
1 parent d983e25 commit 7fc5494

File tree

16 files changed

+14
-49
lines changed

16 files changed

+14
-49
lines changed

app/code/Magento/CustomerGraphQl/Model/Resolver/ChangePassword.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function resolve(
7373
array $args = null
7474
) {
7575
/** @var ContextInterface $context */
76-
if (false === $context->getExtensionAttributes()->isCustomer()) {
76+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
7777
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
7878
}
7979

app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomerAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function resolve(
5454
array $args = null
5555
) {
5656
/** @var ContextInterface $context */
57-
if (false === $context->getExtensionAttributes()->isCustomer()) {
57+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
5858
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
5959
}
6060

app/code/Magento/CustomerGraphQl/Model/Resolver/Customer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function resolve(
5353
array $args = null
5454
) {
5555
/** @var ContextInterface $context */
56-
if (false === $context->getExtensionAttributes()->isCustomer()) {
56+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
5757
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
5858
}
5959

app/code/Magento/CustomerGraphQl/Model/Resolver/DeleteCustomerAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function resolve(
5454
array $args = null
5555
) {
5656
/** @var ContextInterface $context */
57-
if (false === $context->getExtensionAttributes()->isCustomer()) {
57+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
5858
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
5959
}
6060

app/code/Magento/CustomerGraphQl/Model/Resolver/RevokeCustomerToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function resolve(
4444
array $args = null
4545
) {
4646
/** @var ContextInterface $context */
47-
if (false === $context->getExtensionAttributes()->isCustomer()) {
47+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
4848
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
4949
}
5050

app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function resolve(
6262
array $args = null
6363
) {
6464
/** @var ContextInterface $context */
65-
if (false === $context->getExtensionAttributes()->isCustomer()) {
65+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
6666
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
6767
}
6868

app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomerAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function resolve(
6363
array $args = null
6464
) {
6565
/** @var ContextInterface $context */
66-
if (false === $context->getExtensionAttributes()->isCustomer()) {
66+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
6767
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
6868
}
6969

app/code/Magento/DownloadableGraphQl/Model/Resolver/CustomerDownloadableProducts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function resolve(
5555
array $args = null
5656
) {
5757
/** @var ContextInterface $context */
58-
if (false === $context->getExtensionAttributes()->isCustomer()) {
58+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
5959
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
6060
}
6161

app/code/Magento/DownloadableGraphQl/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"php": "~7.1.3||~7.2.0",
77
"magento/module-catalog": "*",
88
"magento/module-downloadable": "*",
9+
"magento/module-graph-ql": "*",
910
"magento/framework": "*"
1011
},
1112
"suggest": {

app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private function createBillingAddress(
102102
if (null === $customerAddressId) {
103103
$billingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);
104104
} else {
105-
if (false === $context->getExtensionAttributes()->isCustomer()) {
105+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
106106
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
107107
}
108108

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
6868
if (null === $customerAddressId) {
6969
$shippingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput);
7070
} else {
71-
if (false === $context->getExtensionAttributes()->isCustomer()) {
71+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
7272
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
7373
}
7474

app/code/Magento/SalesGraphQl/Model/Resolver/Orders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function resolve(
4444
array $args = null
4545
) {
4646
/** @var ContextInterface $context */
47-
if (false === $context->getExtensionAttributes()->isCustomer()) {
47+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
4848
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
4949
}
5050

app/code/Magento/VaultGraphQl/Model/Resolver/DeletePaymentToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function resolve(
5555
array $args = null
5656
) {
5757
/** @var ContextInterface $context */
58-
if (false === $context->getExtensionAttributes()->isCustomer()) {
58+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
5959
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
6060
}
6161

app/code/Magento/VaultGraphQl/Model/Resolver/PaymentTokens.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function resolve(
4444
array $args = null
4545
) {
4646
/** @var ContextInterface $context */
47-
if (false === $context->getExtensionAttributes()->isCustomer()) {
47+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
4848
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
4949
}
5050

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/ChangeCustomerPasswordTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,6 @@ private function lockCustomer(int $customerId): void
193193
$this->customerAuthUpdate->saveAuth($customerId);
194194
}
195195

196-
/**
197-
* @param int $customerId
198-
*
199-
* @return void
200-
* @throws LocalizedException
201-
*/
202-
private function setCustomerConfirmation(int $customerId): void
203-
{
204-
$customer = $this->customerRepository->getById($customerId);
205-
$customer->setConfirmation('d5a21f15bd4cc21bd1b21ef6d9989a38');
206-
$this->customerRepository->save($customer);
207-
}
208-
209196
/**
210197
* @param $currentPassword
211198
* @param $newPassword

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/DeleteCustomerAddressTest.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -224,29 +224,6 @@ public function testDeleteAnotherCustomerAddress()
224224
$this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
225225
}
226226

227-
/**
228-
* @magentoApiDataFixture Magento/Customer/_files/inactive_customer.php
229-
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php
230-
* @magentoApiDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php
231-
*
232-
* @expectedException Exception
233-
* @expectedExceptionMessage The account sign-in was incorrect or your account is disabled temporarily.
234-
*/
235-
public function testDeleteInactiveCustomerAddress()
236-
{
237-
$userName = '[email protected]';
238-
$password = 'password';
239-
$addressId = 2;
240-
241-
$mutation
242-
= <<<MUTATION
243-
mutation {
244-
deleteCustomerAddress(id: {$addressId})
245-
}
246-
MUTATION;
247-
$this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
248-
}
249-
250227
/**
251228
* @magentoApiDataFixture Magento/Customer/_files/customer.php
252229
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php

0 commit comments

Comments
 (0)