Skip to content

Commit 42f1b60

Browse files
RachanaRachana
authored andcommitted
Merge remote-tracking branch 'sprank/fix-38238' into AC10654
2 parents 4745100 + 6dddacb commit 42f1b60

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

app/code/Magento/Security/Model/Plugin/AccountManagement.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Security\Model\Plugin;
79

810
use Magento\Customer\Model\AccountManagement as AccountManagementOriginal;
11+
use Magento\Framework\App\Area;
912
use Magento\Framework\App\ObjectManager;
1013
use Magento\Framework\Config\ScopeInterface;
1114
use Magento\Framework\Exception\SecurityViolationException;
@@ -58,6 +61,8 @@ public function __construct(
5861
}
5962

6063
/**
64+
* Security check before reset password
65+
*
6166
* @param AccountManagementOriginal $accountManagement
6267
* @param string $email
6368
* @param string $template
@@ -73,8 +78,10 @@ public function beforeInitiatePasswordReset(
7378
$template,
7479
$websiteId = null
7580
) {
76-
if ($this->scope->getCurrentScope() == \Magento\Framework\App\Area::AREA_FRONTEND
77-
|| $this->passwordRequestEvent == PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST) {
81+
if ($this->scope->getCurrentScope() == Area::AREA_FRONTEND
82+
|| $this->passwordRequestEvent == PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST
83+
|| ($this->scope->getCurrentScope() == Area::AREA_WEBAPI_REST
84+
&& $this->passwordRequestEvent == PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST)) {
7885
$this->securityManager->performSecurityCheck(
7986
$this->passwordRequestEvent,
8087
$email

app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testBeforeInitiatePasswordReset($area, $passwordRequestEvent, $e
9292
]
9393
);
9494

95-
$this->scope->expects($this->once())
95+
$this->scope->expects($this->any())
9696
->method('getCurrentScope')
9797
->willReturn($area);
9898

@@ -119,6 +119,7 @@ public function beforeInitiatePasswordResetDataProvider()
119119
[Area::AREA_FRONTEND, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
120120
// This should never happen, but let's cover it with tests
121121
[Area::AREA_FRONTEND, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
122+
[Area::AREA_WEBAPI_REST, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
122123
];
123124
}
124125
}

0 commit comments

Comments
 (0)