Skip to content

Commit 4efc1ed

Browse files
committed
AC-10886: admin Password update
1 parent a97b692 commit 4efc1ed

File tree

2 files changed

+23
-14
lines changed
  • app/code/Magento/Backend/Controller/Adminhtml/System/Account
  • dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/System

2 files changed

+23
-14
lines changed

app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Backend\Controller\Adminhtml\System\Account;
77

@@ -12,6 +12,7 @@
1212
use Magento\Framework\Exception\State\UserLockedException;
1313
use Magento\Security\Model\SecurityCookie;
1414
use Magento\Framework\App\Action\HttpPostActionInterface;
15+
use \Magento\User\Model\User;
1516

1617
/**
1718
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -86,19 +87,9 @@ public function execute()
8687
$user->save();
8788
$user->sendNotificationEmailsIfRequired();
8889

89-
// Check which fields were modified after saving
90-
$modifiedFields = [];
91-
$propertiesToCheck = ['password', 'username', 'firstname', 'lastname', 'email'];
92-
93-
foreach ($propertiesToCheck as $property) {
94-
if ($user->getOrigData($property) !== $user->{'get' . ucfirst($property)}()) {
95-
$modifiedFields[] = $property;
96-
}
97-
}
98-
90+
$modifiedFields = $this->getModifiedFields($user);
9991
if (!empty($modifiedFields)) {
10092
$countModifiedFields = count($modifiedFields);
101-
$successMessage = '';
10293
// validate how many fields were modified to display them correctly
10394
if ($countModifiedFields > 1) {
10495
$lastModifiedField = array_pop($modifiedFields);
@@ -139,4 +130,22 @@ public function execute()
139130
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
140131
return $resultRedirect->setPath("*/*/");
141132
}
133+
134+
/**
135+
* Get user modified fields
136+
*
137+
* @param User $user
138+
* @return array
139+
*/
140+
private function getModifiedFields(User $user)
141+
{
142+
$modifiedFields = [];
143+
$propertiesToCheck = ['password', 'username', 'firstname', 'lastname', 'email'];
144+
foreach ($propertiesToCheck as $property) {
145+
if ($user->getOrigData($property) !== $user->{'get' . ucfirst($property)}()) {
146+
$modifiedFields[] = $property;
147+
}
148+
}
149+
return $modifiedFields;
150+
}
142151
}

dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testSaveAction($password, $passwordConfirmation, $isPasswordChan
7272

7373
public static function saveDataProvider()
7474
{
75-
$password = uniqid('1234q');
75+
$password = uniqid('123q');
7676
return [
7777
[$password, $password, true],
7878
[$password, '', false],

0 commit comments

Comments
 (0)