8
8
9
9
use Magento \Security \Model \SecurityManager ;
10
10
use Magento \Framework \App \ObjectManager ;
11
+ use Magento \Backend \App \Action \Context ;
12
+ use Magento \User \Model \UserFactory ;
13
+ use Magento \Security \Model \SecurityManager ;
14
+ use Magento \User \Model \ResourceModel \User \CollectionFactory ;
15
+ use Magento \Framework \Validator \EmailAddress ;
16
+ use Magento \Security \Model \PasswordResetRequestEvent ;
17
+ use Magento \Framework \Exception \SecurityViolationException ;
18
+ use Magento \User \Controller \Adminhtml \Auth ;
11
19
12
- class Forgotpassword extends \ Magento \ User \ Controller \ Adminhtml \ Auth
20
+ class Forgotpassword extends Auth
13
21
{
14
22
/**
15
23
* @var SecurityManager
@@ -19,26 +27,26 @@ class Forgotpassword extends \Magento\User\Controller\Adminhtml\Auth
19
27
/**
20
28
* User model factory
21
29
*
22
- * @var \Magento\User\Model\ResourceModel\User\ CollectionFactory
30
+ * @var CollectionFactory
23
31
*/
24
32
private $ userCollectionFactory ;
25
33
26
34
/**
27
- * @param \Magento\Backend\App\Action\ Context $context
28
- * @param \Magento\User\Model\ UserFactory $userFactory
29
- * @param \Magento\Security\Model\ SecurityManager $securityManager
30
- * @param \Magento\User\Model\ResourceModel\User\ CollectionFactory $userCollectionFactory
35
+ * @param Context $context
36
+ * @param UserFactory $userFactory
37
+ * @param SecurityManager $securityManager
38
+ * @param CollectionFactory $userCollectionFactory
31
39
*/
32
40
public function __construct (
33
- \ Magento \ Backend \ App \ Action \ Context $ context ,
34
- \ Magento \ User \ Model \ UserFactory $ userFactory ,
35
- \ Magento \ Security \ Model \ SecurityManager $ securityManager ,
36
- \ Magento \ User \ Model \ ResourceModel \ User \ CollectionFactory $ userCollectionFactory = null
41
+ Context $ context ,
42
+ UserFactory $ userFactory ,
43
+ SecurityManager $ securityManager ,
44
+ CollectionFactory $ userCollectionFactory = null
37
45
) {
38
46
parent ::__construct ($ context , $ userFactory );
39
47
$ this ->securityManager = $ securityManager ;
40
48
$ this ->userCollectionFactory = $ userCollectionFactory ?:
41
- ObjectManager::getInstance ()->get (\ Magento \ User \ Model \ ResourceModel \ User \ CollectionFactory::class);
49
+ ObjectManager::getInstance ()->get (CollectionFactory::class);
42
50
}
43
51
44
52
/**
@@ -56,18 +64,18 @@ public function execute()
56
64
$ resultRedirect = $ this ->resultRedirectFactory ->create ();
57
65
if (!empty ($ email ) && !empty ($ params )) {
58
66
// Validate received data to be an email address
59
- if (\Zend_Validate::is ($ email , \ Magento \ Framework \ Validator \ EmailAddress::class)) {
67
+ if (\Zend_Validate::is ($ email , EmailAddress::class)) {
60
68
try {
61
69
$ this ->securityManager ->performSecurityCheck (
62
- \ Magento \ Security \ Model \ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST ,
70
+ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST ,
63
71
$ email
64
72
);
65
- } catch (\ Magento \ Framework \ Exception \ SecurityViolationException $ exception ) {
73
+ } catch (SecurityViolationException $ exception ) {
66
74
$ this ->messageManager ->addErrorMessage ($ exception ->getMessage ());
67
75
return $ resultRedirect ->setPath ('admin ' );
68
76
}
69
- $ collection = $ this ->userCollectionFactory ->create ();
70
77
/** @var $collection \Magento\User\Model\ResourceModel\User\Collection */
78
+ $ collection = $ this ->userCollectionFactory ->create ();
71
79
$ collection ->addFieldToFilter ('email ' , $ email );
72
80
$ collection ->load (false );
73
81
@@ -77,7 +85,7 @@ public function execute()
77
85
/** @var \Magento\User\Model\User $user */
78
86
$ user = $ this ->_userFactory ->create ()->load ($ item ->getId ());
79
87
if ($ user ->getId ()) {
80
- $ newPassResetToken = $ this ->_backendHelper ->generateResetPasswordLinkToken ();
88
+ $ newPassResetToken = $ this ->_backendDataHelper ->generateResetPasswordLinkToken ();
81
89
$ user ->changeResetPasswordLinkToken ($ newPassResetToken );
82
90
$ user ->save ();
83
91
$ user ->sendPasswordResetConfirmationEmail ();
@@ -96,7 +104,7 @@ public function execute()
96
104
$ this ->messageManager ->addSuccess (__ ('We \'ll email you a link to reset your password. ' ));
97
105
// @codingStandardsIgnoreEnd
98
106
$ this ->getResponse ()->setRedirect (
99
- $ this ->_backendHelper ->getHomePageUrl ()
107
+ $ this ->_backendDataHelper ->getHomePageUrl ()
100
108
);
101
109
return ;
102
110
} else {
0 commit comments