Skip to content

Commit 611d78c

Browse files
author
Valeriy Nayda
committed
GraphQL-54: [Mutations] My Account: Change Password
1 parent 20e9730 commit 611d78c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,24 @@ public function resolve(
6262
array $value = null,
6363
array $args = null
6464
) {
65-
$customerId = $this->userContext->getUserId();
65+
if (!isset($args['currentPassword'])) {
66+
throw new GraphQlInputException(__('"currentPassword" value should be specified'));
67+
}
68+
69+
if (!isset($args['newPassword'])) {
70+
throw new GraphQlInputException(__('"newPassword" value should be specified'));
71+
}
6672

67-
if ($customerId === 0 || $customerId === null) {
73+
$customerId = (int)$this->userContext->getUserId();
74+
if ($customerId === 0) {
6875
throw new GraphQlAuthorizationException(
6976
__(
7077
'Current customer does not have access to the resource "%1"',
7178
[Customer::ENTITY]
7279
)
7380
);
7481
}
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-
}
82+
8183
$this->accountManagement->changePasswordById($customerId, $args['currentPassword'], $args['newPassword']);
8284
$data = $this->customerResolver->getCustomerById($customerId);
8385

0 commit comments

Comments
 (0)