From 3a208453565d86e428c6f554acbd2d7667304659 Mon Sep 17 00:00:00 2001 From: IrinaZhadzinets Date: Mon, 20 Jun 2022 12:44:08 +0300 Subject: [PATCH 1/4] scandipwa/scandipwa#2685 - Add validation for empty order id --- src/Model/Resolver/CreateCustomer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Resolver/CreateCustomer.php b/src/Model/Resolver/CreateCustomer.php index c2300eb..513d941 100644 --- a/src/Model/Resolver/CreateCustomer.php +++ b/src/Model/Resolver/CreateCustomer.php @@ -87,7 +87,7 @@ public function resolve( ) { $output = parent::resolve($field, $context, $info, $value, $args); - if (isset($args['input']['orderID']) && isset($output['customer']['id'])) { + if (isset($args['input']['orderID']) && !empty($args['input']['orderID']) && isset($output['customer']['id'])) { $orderModel = $this->orderFactory->create()->loadByIncrementId($args['input']['orderID']); $orderModel->setCustomerId($output['customer']['id']); From 91f43da51146acf9bd7f47912af52259018353d3 Mon Sep 17 00:00:00 2001 From: Azizbek Rasulov Date: Tue, 21 Jun 2022 22:28:36 +0500 Subject: [PATCH 2/4] unlocking the user if the password is reset successfully --- src/Model/Resolver/ResetPassword.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Model/Resolver/ResetPassword.php b/src/Model/Resolver/ResetPassword.php index 123f0f1..80d62f7 100644 --- a/src/Model/Resolver/ResetPassword.php +++ b/src/Model/Resolver/ResetPassword.php @@ -14,6 +14,8 @@ namespace ScandiPWA\CustomerGraphQl\Model\Resolver; use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Model\AuthenticationInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\InputException; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Exception\GraphQlInputException; @@ -42,6 +44,13 @@ class ResetPassword implements ResolverInterface { */ protected $customerRepository; + protected function getAuthentication() + { + return ObjectManager::getInstance()->get( + AuthenticationInterface::class + ); + } + /** * ResetPassword constructor. * @@ -94,6 +103,7 @@ public function resolve( try { $this->accountManagement->resetPassword($customerEmail, $resetPasswordToken, $password); + $this->getAuthentication()->unlock($customerId); $this->session->unsRpToken(); return [ 'status' => self::STATUS_PASSWORD_UPDATED ]; } catch (InputException $e) { From eafa76f3fbd33c6ef8949f0f522c00b725bafbc0 Mon Sep 17 00:00:00 2001 From: Azizbek Rasulov Date: Fri, 24 Jun 2022 10:47:11 +0500 Subject: [PATCH 3/4] added depecndecies of the function to the cunstruct --- src/Model/Resolver/ResetPassword.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Model/Resolver/ResetPassword.php b/src/Model/Resolver/ResetPassword.php index 80d62f7..a0f9c1c 100644 --- a/src/Model/Resolver/ResetPassword.php +++ b/src/Model/Resolver/ResetPassword.php @@ -59,11 +59,15 @@ protected function getAuthentication() public function __construct( Session $customerSession, CustomerRepositoryInterface $customerRepository, - AccountManagementInterface $accountManagement + AccountManagementInterface $accountManagement, + AuthenticationInterface $authenctication, + ObjectManager $objectManager ) { $this->session = $customerSession; $this->accountManagement = $accountManagement; $this->customerRepository = $customerRepository; + $this-> authetication = $authenctication; + $this-> objecManaget = $objectManager; } /** From deb39d3c765250a596cf499026daeca3cd216e2d Mon Sep 17 00:00:00 2001 From: Azizbek Rasulov Date: Fri, 24 Jun 2022 15:48:50 +0500 Subject: [PATCH 4/4] refactored code --- src/Model/Resolver/ResetPassword.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Model/Resolver/ResetPassword.php b/src/Model/Resolver/ResetPassword.php index a0f9c1c..d84f554 100644 --- a/src/Model/Resolver/ResetPassword.php +++ b/src/Model/Resolver/ResetPassword.php @@ -44,12 +44,10 @@ class ResetPassword implements ResolverInterface { */ protected $customerRepository; - protected function getAuthentication() - { - return ObjectManager::getInstance()->get( - AuthenticationInterface::class - ); - } + /** + * @var AuthenticationInterface + */ + protected $authentication; /** * ResetPassword constructor. @@ -60,14 +58,12 @@ public function __construct( Session $customerSession, CustomerRepositoryInterface $customerRepository, AccountManagementInterface $accountManagement, - AuthenticationInterface $authenctication, - ObjectManager $objectManager + AuthenticationInterface $authenctication ) { $this->session = $customerSession; $this->accountManagement = $accountManagement; $this->customerRepository = $customerRepository; - $this-> authetication = $authenctication; - $this-> objecManaget = $objectManager; + $this->authentication = $authenctication; } /** @@ -107,7 +103,7 @@ public function resolve( try { $this->accountManagement->resetPassword($customerEmail, $resetPasswordToken, $password); - $this->getAuthentication()->unlock($customerId); + $this->authentication->unlock($customerId); $this->session->unsRpToken(); return [ 'status' => self::STATUS_PASSWORD_UPDATED ]; } catch (InputException $e) {