Skip to content

Commit f883d96

Browse files
pradeep1819devarul
authored andcommitted
ACP2E-1486: No Email confirmation when changing password via Graphql
1 parent 4dba230 commit f883d96

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
namespace Magento\CustomerGraphQl\Model\Resolver;
99

1010
use Magento\Customer\Api\AccountManagementInterface;
11+
use Magento\Customer\Model\EmailNotificationInterface;
1112
use Magento\CustomerGraphQl\Model\Customer\CheckCustomerPassword;
1213
use Magento\CustomerGraphQl\Model\Customer\ExtractCustomerData;
1314
use Magento\CustomerGraphQl\Model\Customer\GetCustomer;
15+
use Magento\Framework\App\ObjectManager;
1416
use Magento\Framework\Exception\LocalizedException;
1517
use Magento\Framework\GraphQl\Config\Element\Field;
1618
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
@@ -44,22 +46,31 @@ class ChangePassword implements ResolverInterface
4446
*/
4547
private $extractCustomerData;
4648

49+
/**
50+
* @var EmailNotificationInterface
51+
*/
52+
private $emailNotification;
53+
4754
/**
4855
* @param GetCustomer $getCustomer
4956
* @param CheckCustomerPassword $checkCustomerPassword
5057
* @param AccountManagementInterface $accountManagement
5158
* @param ExtractCustomerData $extractCustomerData
59+
* @param EmailNotificationInterface|null $emailNotification
5260
*/
5361
public function __construct(
5462
GetCustomer $getCustomer,
5563
CheckCustomerPassword $checkCustomerPassword,
5664
AccountManagementInterface $accountManagement,
57-
ExtractCustomerData $extractCustomerData
65+
ExtractCustomerData $extractCustomerData,
66+
?EmailNotificationInterface $emailNotification = null
5867
) {
5968
$this->getCustomer = $getCustomer;
6069
$this->checkCustomerPassword = $checkCustomerPassword;
6170
$this->accountManagement = $accountManagement;
6271
$this->extractCustomerData = $extractCustomerData;
72+
$this->emailNotification = $emailNotification
73+
?? ObjectManager::getInstance()->get(EmailNotificationInterface::class);
6374
}
6475

6576
/**
@@ -89,12 +100,25 @@ public function resolve(
89100
$this->checkCustomerPassword->execute($args['currentPassword'], $customerId);
90101

91102
try {
92-
$this->accountManagement->changePasswordById($customerId, $args['currentPassword'], $args['newPassword']);
103+
$isPasswordChanged = $this->accountManagement->changePasswordById(
104+
$customerId,
105+
$args['currentPassword'],
106+
$args['newPassword']
107+
);
93108
} catch (LocalizedException $e) {
94109
throw new GraphQlInputException(__($e->getMessage()), $e);
95110
}
96111

97112
$customer = $this->getCustomer->execute($context);
113+
114+
if ($isPasswordChanged) {
115+
$this->emailNotification->credentialsChanged(
116+
$customer,
117+
$customer->getEmail(),
118+
$isPasswordChanged
119+
);
120+
}
121+
98122
return $this->extractCustomerData->execute($customer);
99123
}
100124
}

0 commit comments

Comments
 (0)