Skip to content

Commit 0a9ae1e

Browse files
AnshuMishra17gelanivishal
authored andcommitted
changes as per comments on GitHub
1 parent 0322eb6 commit 0a9ae1e

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

app/code/Magento/User/Controller/Adminhtml/Auth.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
namespace Magento\User\Controller\Adminhtml;
88

99
use Magento\Framework\Encryption\Helper\Security;
10-
use Magento\Framework\App\ObjectManager;
1110
use Magento\Backend\App\AbstractAction;
1211
use Magento\Backend\App\Action\Context;
1312
use Magento\User\Model\UserFactory;
14-
use Magento\Backend\Helper\Data;
1513
use Magento\Framework\Exception\LocalizedException;
1614

1715
/**
@@ -25,27 +23,19 @@ abstract class Auth extends AbstractAction
2523
* @var UserFactory
2624
*/
2725
protected $_userFactory;
28-
29-
/**
30-
* @var Data
31-
*/
32-
protected $_backendDataHelper;
3326

3427
/**
3528
* Construct
3629
*
3730
* @param Context $context
3831
* @param UserFactory $userFactory
39-
* @param Data $backendDataHelper
4032
*/
4133
public function __construct(
4234
Context $context,
43-
UserFactory $userFactory,
44-
Data $backendDataHelper = null
35+
UserFactory $userFactory
4536
) {
4637
parent::__construct($context);
4738
$this->_userFactory = $userFactory;
48-
$this->_backendDataHelper = $backendDataHelper ?: ObjectManager::getInstance()->get(Data::class);
4939
}
5040

5141
/**

app/code/Magento/User/Controller/Adminhtml/Auth/Forgotpassword.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,27 @@
1515
use Magento\Security\Model\PasswordResetRequestEvent;
1616
use Magento\Framework\Exception\SecurityViolationException;
1717
use Magento\User\Controller\Adminhtml\Auth;
18+
use Magento\Backend\Helper\Data;
1819

1920
class Forgotpassword extends Auth
2021
{
2122
/**
2223
* @var SecurityManager
2324
*/
2425
protected $securityManager;
25-
26+
2627
/**
2728
* User model factory
2829
*
2930
* @var CollectionFactory
3031
*/
3132
private $userCollectionFactory;
3233

34+
/**
35+
* @var Data
36+
*/
37+
private $backendDataHelper;
38+
3339
/**
3440
* @param Context $context
3541
* @param UserFactory $userFactory
@@ -40,12 +46,15 @@ public function __construct(
4046
Context $context,
4147
UserFactory $userFactory,
4248
SecurityManager $securityManager,
43-
CollectionFactory $userCollectionFactory = null
49+
CollectionFactory $userCollectionFactory = null,
50+
Data $backendDataHelper = null
4451
) {
4552
parent::__construct($context, $userFactory);
4653
$this->securityManager = $securityManager;
4754
$this->userCollectionFactory = $userCollectionFactory ?:
4855
ObjectManager::getInstance()->get(CollectionFactory::class);
56+
$this->backendDataHelper = $backendDataHelper ?:
57+
ObjectManager::getInstance()->get(Data::class);
4958
}
5059

5160
/**
@@ -84,7 +93,7 @@ public function execute()
8493
/** @var \Magento\User\Model\User $user */
8594
$user = $this->_userFactory->create()->load($item->getId());
8695
if ($user->getId()) {
87-
$newPassResetToken = $this->_backendDataHelper->generateResetPasswordLinkToken();
96+
$newPassResetToken = $this->backendDataHelper->generateResetPasswordLinkToken();
8897
$user->changeResetPasswordLinkToken($newPassResetToken);
8998
$user->save();
9099
$user->sendPasswordResetConfirmationEmail();
@@ -103,7 +112,7 @@ public function execute()
103112
$this->messageManager->addSuccess(__('We\'ll email you a link to reset your password.'));
104113
// @codingStandardsIgnoreEnd
105114
$this->getResponse()->setRedirect(
106-
$this->_backendDataHelper->getHomePageUrl()
115+
$this->backendDataHelper->getHomePageUrl()
107116
);
108117
return;
109118
} else {

app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@
77
namespace Magento\User\Controller\Adminhtml\Auth;
88

99
use Magento\User\Controller\Adminhtml\Auth;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Backend\Helper\Data;
1012

1113
class ResetPasswordPost extends Auth
1214
{
15+
/**
16+
* @var Data
17+
*/
18+
private $backendDataHelper;
19+
20+
/**
21+
* @param Context $context
22+
* @param Data $backendDataHelper
23+
*/
24+
public function __construct(
25+
Context $context,
26+
Data $backendDataHelper = null
27+
) {
28+
parent::__construct($context, $userFactory);
29+
$this->backendDataHelper = $backendDataHelper ?: ObjectManager::getInstance()->get(Data::class);
30+
}
1331
/**
1432
* Reset forgotten password
1533
*
@@ -29,7 +47,7 @@ public function execute()
2947
} catch (\Exception $exception) {
3048
$this->messageManager->addError(__('Your password reset link has expired.'));
3149
$this->getResponse()->setRedirect(
32-
$this->_backendDataHelper->getHomePageUrl()
50+
$this->backendDataHelper->getHomePageUrl()
3351
);
3452
return;
3553
}
@@ -55,7 +73,7 @@ public function execute()
5573
$user->save();
5674
$this->messageManager->addSuccess(__('You updated your password.'));
5775
$this->getResponse()->setRedirect(
58-
$this->_backendDataHelper->getHomePageUrl()
76+
$this->backendDataHelper->getHomePageUrl()
5977
);
6078
}
6179
} catch (\Magento\Framework\Validator\Exception $exception) {

0 commit comments

Comments
 (0)