Skip to content

Commit ac21289

Browse files
committed
MAGETWO-95238: Cannot reset customer password from Admin Panel
1 parent b4c1595 commit ac21289

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

app/code/Magento/Customer/Block/Adminhtml/Edit/ResetPasswordButton.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ public function getButtonData()
2525
$data = [
2626
'label' => __('Reset Password'),
2727
'class' => 'reset reset-password',
28-
'data_attribute' => [
29-
'url' => $this->getResetPasswordUrl()
30-
],
31-
'on_click' => '',
28+
'on_click' => sprintf("location.href = '%s';", $this->getResetPasswordUrl()),
3229
'sort_order' => 60,
3330
];
3431
}

app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
*/
66
namespace Magento\Customer\Controller\Adminhtml\Index;
77

8-
use Magento\Framework\App\Action\HttpPostActionInterface;
8+
use Magento\Framework\App\Action\HttpGetActionInterface;
99
use Magento\Framework\Exception\NoSuchEntityException;
1010
use Magento\Framework\Exception\SecurityViolationException;
1111

12-
class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index implements HttpPostActionInterface
12+
class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index implements HttpGetActionInterface
1313
{
1414
/**
1515
* Reset password handler

app/code/Magento/Customer/view/adminhtml/web/edit/post-wrapper.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,4 @@ define([
4444

4545
return false;
4646
});
47-
48-
$('#resetPassword').click(function () {
49-
var url = $('#resetPassword').data('url');
50-
51-
getForm(url).appendTo('body').submit();
52-
53-
return false;
54-
});
5547
});

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testResetPasswordSuccess()
3434
$this->passwordResetRequestEventCreate(
3535
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
3636
);
37-
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
37+
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
3838
$this->dispatch('backend/customer/index/resetPassword');
3939
$this->assertSessionMessages(
4040
$this->equalTo(['The customer will receive an email with a link to reset password.']),
@@ -44,18 +44,18 @@ public function testResetPasswordSuccess()
4444
}
4545

4646
/**
47-
* Checks reset password functionality cannot be performed with GET request
47+
* Checks reset password functionality cannot be performed with POST request
4848
*
4949
* @magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0
5050
* @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0
5151
* @magentoDataFixture Magento/Customer/_files/customer.php
5252
*/
53-
public function testResetPasswordWithGet()
53+
public function testResetPasswordWithPost()
5454
{
5555
$this->passwordResetRequestEventCreate(
5656
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
5757
);
58-
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
58+
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
5959
$this->dispatch('backend/customer/index/resetPassword');
6060
$this->assertEquals('noroute', $this->getRequest()->getControllerName());
6161
}
@@ -74,7 +74,7 @@ public function testResetPasswordMinTimeError()
7474
$this->passwordResetRequestEventCreate(
7575
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
7676
);
77-
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
77+
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
7878
$this->dispatch('backend/customer/index/resetPassword');
7979
$this->assertSessionMessages(
8080
$this->equalTo(['The customer will receive an email with a link to reset password.']),
@@ -97,7 +97,7 @@ public function testResetPasswordLimitError()
9797
$this->passwordResetRequestEventCreate(
9898
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
9999
);
100-
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
100+
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
101101
$this->dispatch('backend/customer/index/resetPassword');
102102
$this->assertSessionMessages(
103103
$this->equalTo(['The customer will receive an email with a link to reset password.']),
@@ -122,7 +122,7 @@ public function testResetPasswordWithSecurityViolationException()
122122
$this->passwordResetRequestEventCreate(
123123
\Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST
124124
);
125-
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
125+
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
126126
$this->dispatch('backend/customer/index/resetPassword');
127127
$this->assertSessionMessages(
128128
$this->equalTo(['The customer will receive an email with a link to reset password.']),

0 commit comments

Comments
 (0)