|
8 | 8 | namespace Magento\CustomerGraphQl\Model\Customer;
|
9 | 9 |
|
10 | 10 | use Magento\Customer\Api\Data\CustomerInterface;
|
| 11 | +use Magento\Framework\Exception\LocalizedException; |
11 | 12 | use Magento\Framework\Exception\NoSuchEntityException;
|
12 | 13 | use Magento\Framework\GraphQl\Exception\GraphQlAlreadyExistsException;
|
13 | 14 | use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
|
@@ -89,17 +90,20 @@ public function __construct(
|
89 | 90 | * @throws GraphQlAuthenticationException
|
90 | 91 | * @throws GraphQlInputException
|
91 | 92 | * @throws GraphQlNoSuchEntityException
|
| 93 | + * @throws NoSuchEntityException |
| 94 | + * @throws LocalizedException |
92 | 95 | */
|
93 | 96 | public function execute(CustomerInterface $customer, array $data, StoreInterface $store): void
|
94 | 97 | {
|
95 | 98 | if (isset($data['email']) && $customer->getEmail() !== $data['email']) {
|
96 |
| - if (!isset($data['password']) || empty($data['password'])) { |
| 99 | + if (empty($data['password'])) { |
97 | 100 | throw new GraphQlInputException(__('Provide the current "password" to change "email".'));
|
98 | 101 | }
|
99 | 102 |
|
100 | 103 | $this->checkCustomerPassword->execute($data['password'], (int)$customer->getId());
|
101 | 104 | $customer->setEmail($data['email']);
|
102 | 105 | }
|
| 106 | + |
103 | 107 | $this->validateCustomerData->execute($data);
|
104 | 108 | $filteredData = array_diff_key($data, array_flip($this->restrictedKeys));
|
105 | 109 | $this->dataObjectHelper->populateWithArray($customer, $filteredData, CustomerInterface::class);
|
|
0 commit comments