Skip to content

Commit 2fc07a5

Browse files
committed
Merge remote-tracking branch 'trigger/MAGETWO-95238' into BugFixPR
2 parents 6b298ee + 32686ec commit 2fc07a5

File tree

7 files changed

+56
-24
lines changed

7 files changed

+56
-24
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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
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+
/**
13+
* Reset password controller
14+
*
15+
* @package Magento\Customer\Controller\Adminhtml\Index
16+
*/
17+
class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index implements HttpGetActionInterface
1318
{
1419
/**
1520
* Reset password handler

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminCustomerMainActionsSection">
1212
<element name="saveButton" type="button" selector="#save" timeout="30"/>
13+
<element name="resetPassword" type="button" selector="#resetPassword" timeout="30"/>
1314
</section>
1415
</sections>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminResetCustomerPasswordTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Admin should be able to reset an existing customer's password"/>
15+
<description value="Admin should be able to reset customer password"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="MAGETWO-30875"/>
18+
<group value="customer"/>
19+
</annotations>
20+
<before>
21+
<createData entity="Simple_US_Customer" stepKey="customer"/>
22+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
23+
</before>
24+
<after>
25+
<deleteData createDataKey="customer" stepKey="deleteCustomer"/>
26+
<actionGroup ref="logout" stepKey="logout"/>
27+
</after>
28+
<!--Edit customer info-->
29+
<actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="OpenEditCustomerFrom">
30+
<argument name="customer" value="$$customer$$"/>
31+
</actionGroup>
32+
<click selector="{{AdminCustomerMainActionsSection.resetPassword}}" stepKey="resetPassword"/>
33+
<see userInput="The customer will receive an email with a link to reset password." stepKey="messageThatLinkToPasswordResetIsSent"/>
34+
</test>
35+
</tests>
36+
37+

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.']),

dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ public function testValidateCustomerWithAddressFailure()
738738
public function testResetPasswordActionNoCustomerId()
739739
{
740740
// No customer ID in post, will just get redirected to base
741-
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
741+
$this->getRequest()->setMethod(HttpRequest::METHOD_GET);
742742
$this->dispatch('backend/customer/index/resetPassword');
743743
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
744744
}
@@ -749,7 +749,7 @@ public function testResetPasswordActionNoCustomerId()
749749
public function testResetPasswordActionBadCustomerId()
750750
{
751751
// Bad customer ID in post, will just get redirected to base
752-
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
752+
$this->getRequest()->setMethod(HttpRequest::METHOD_GET);
753753
$this->getRequest()->setPostValue(['customer_id' => '789']);
754754
$this->dispatch('backend/customer/index/resetPassword');
755755
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
@@ -761,7 +761,7 @@ public function testResetPasswordActionBadCustomerId()
761761
public function testResetPasswordActionSuccess()
762762
{
763763
$this->getRequest()->setPostValue(['customer_id' => '1']);
764-
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
764+
$this->getRequest()->setMethod(HttpRequest::METHOD_GET);
765765
$this->dispatch('backend/customer/index/resetPassword');
766766
$this->assertSessionMessages(
767767
$this->equalTo(['The customer will receive an email with a link to reset password.']),

0 commit comments

Comments
 (0)