Skip to content

Commit 5d436f1

Browse files
committed
Add checks for input parameters
1 parent 8cb2364 commit 5d436f1

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Magento\Framework\GraphQl\Config\Element\Field;
1515
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1616
use Magento\Framework\GraphQl\Query\Resolver\Value;
17-
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
1817
use Magento\Framework\GraphQl\Query\ResolverInterface;
1918
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
2019

@@ -38,27 +37,19 @@ class ChangePassword implements ResolverInterface
3837
*/
3938
private $customerResolver;
4039

41-
/**
42-
* @var ValueFactory
43-
*/
44-
private $valueFactory;
45-
4640
/**
4741
* @param UserContextInterface $userContext
4842
* @param AccountManagementInterface $accountManagement
4943
* @param CustomerDataProvider $customerResolver
50-
* @param ValueFactory $valueFactory
5144
*/
5245
public function __construct(
5346
UserContextInterface $userContext,
5447
AccountManagementInterface $accountManagement,
55-
CustomerDataProvider $customerResolver,
56-
ValueFactory $valueFactory
48+
CustomerDataProvider $customerResolver
5749
) {
5850
$this->userContext = $userContext;
5951
$this->accountManagement = $accountManagement;
6052
$this->customerResolver = $customerResolver;
61-
$this->valueFactory = $valueFactory;
6253
}
6354

6455
/**
@@ -81,13 +72,15 @@ public function resolve(
8172
)
8273
);
8374
}
84-
75+
if (!isset($args['currentPassword'])) {
76+
throw new GraphQlInputException(__('"currentPassword" value should be specified'));
77+
}
78+
if (!isset($args['newPassword'])) {
79+
throw new GraphQlInputException(__('"newPassword" value should be specified'));
80+
}
8581
$this->accountManagement->changePasswordById($customerId, $args['currentPassword'], $args['newPassword']);
8682
$data = $this->customerResolver->getCustomerById($customerId);
87-
$result = function () use ($data) {
88-
return !empty($data) ? $data : [];
89-
};
9083

91-
return $this->valueFactory->create($result);
84+
return !empty($data) ? $data : [];
9285
}
9386
}

0 commit comments

Comments
 (0)