Skip to content

Commit b8b6ade

Browse files
committed
MAGETWO-95238: Cannot reset customer password from Admin Panel
1 parent 09cfa64 commit b8b6ade

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
class ResetPasswordButton extends GenericButton implements ButtonProviderInterface
1414
{
1515
/**
16+
* Retrieve button-specified settings
17+
*
1618
* @return array
1719
*/
1820
public function getButtonData()
@@ -23,14 +25,19 @@ public function getButtonData()
2325
$data = [
2426
'label' => __('Reset Password'),
2527
'class' => 'reset reset-password',
26-
'on_click' => sprintf("location.href = '%s';", $this->getResetPasswordUrl()),
28+
'data_attribute' => [
29+
'url' => $this->getResetPasswordUrl()
30+
],
31+
'on_click' => '',
2732
'sort_order' => 60,
2833
];
2934
}
3035
return $data;
3136
}
3237

3338
/**
39+
* Get reset password url
40+
*
3441
* @return string
3542
*/
3643
public function getResetPasswordUrl()

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ 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+
});
4755
});

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ public function testResetPasswordSuccess()
4343
$this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit'));
4444
}
4545

46+
/**
47+
* Checks reset password functionality cannot be performed with GET request
48+
*
49+
* @magentoConfigFixture current_store customer/password/limit_password_reset_requests_method 0
50+
* @magentoConfigFixture current_store customer/password/min_time_between_password_reset_requests 0
51+
* @magentoDataFixture Magento/Customer/_files/customer.php
52+
*/
53+
public function testResetPasswordWithGet()
54+
{
55+
$this->passwordResetRequestEventCreate(
56+
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
57+
);
58+
$this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_GET);
59+
$this->dispatch('backend/customer/index/resetPassword');
60+
$this->assertEquals('noroute', $this->getRequest()->getControllerName());
61+
}
62+
4663
/**
4764
* Checks reset password functionality with default restrictive min time between
4865
* password reset requests and customer reset request event.

0 commit comments

Comments
 (0)