88
99use Magento \Security \Model \SecurityManager ;
1010use 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 ;
1119
12- class Forgotpassword extends \ Magento \ User \ Controller \ Adminhtml \ Auth
20+ class Forgotpassword extends Auth
1321{
1422 /**
1523 * @var SecurityManager
@@ -19,26 +27,26 @@ class Forgotpassword extends \Magento\User\Controller\Adminhtml\Auth
1927 /**
2028 * User model factory
2129 *
22- * @var \Magento\User\Model\ResourceModel\User\ CollectionFactory
30+ * @var CollectionFactory
2331 */
2432 private $ userCollectionFactory ;
2533
2634 /**
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
3139 */
3240 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
3745 ) {
3846 parent ::__construct ($ context , $ userFactory );
3947 $ this ->securityManager = $ securityManager ;
4048 $ this ->userCollectionFactory = $ userCollectionFactory ?:
41- ObjectManager::getInstance ()->get (\ Magento \ User \ Model \ ResourceModel \ User \ CollectionFactory::class);
49+ ObjectManager::getInstance ()->get (CollectionFactory::class);
4250 }
4351
4452 /**
@@ -56,18 +64,18 @@ public function execute()
5664 $ resultRedirect = $ this ->resultRedirectFactory ->create ();
5765 if (!empty ($ email ) && !empty ($ params )) {
5866 // 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)) {
6068 try {
6169 $ this ->securityManager ->performSecurityCheck (
62- \ Magento \ Security \ Model \ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST ,
70+ PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST ,
6371 $ email
6472 );
65- } catch (\ Magento \ Framework \ Exception \ SecurityViolationException $ exception ) {
73+ } catch (SecurityViolationException $ exception ) {
6674 $ this ->messageManager ->addErrorMessage ($ exception ->getMessage ());
6775 return $ resultRedirect ->setPath ('admin ' );
6876 }
69- $ collection = $ this ->userCollectionFactory ->create ();
7077 /** @var $collection \Magento\User\Model\ResourceModel\User\Collection */
78+ $ collection = $ this ->userCollectionFactory ->create ();
7179 $ collection ->addFieldToFilter ('email ' , $ email );
7280 $ collection ->load (false );
7381
@@ -77,7 +85,7 @@ public function execute()
7785 /** @var \Magento\User\Model\User $user */
7886 $ user = $ this ->_userFactory ->create ()->load ($ item ->getId ());
7987 if ($ user ->getId ()) {
80- $ newPassResetToken = $ this ->_backendHelper ->generateResetPasswordLinkToken ();
88+ $ newPassResetToken = $ this ->_backendDataHelper ->generateResetPasswordLinkToken ();
8189 $ user ->changeResetPasswordLinkToken ($ newPassResetToken );
8290 $ user ->save ();
8391 $ user ->sendPasswordResetConfirmationEmail ();
@@ -96,7 +104,7 @@ public function execute()
96104 $ this ->messageManager ->addSuccess (__ ('We \'ll email you a link to reset your password. ' ));
97105 // @codingStandardsIgnoreEnd
98106 $ this ->getResponse ()->setRedirect (
99- $ this ->_backendHelper ->getHomePageUrl ()
107+ $ this ->_backendDataHelper ->getHomePageUrl ()
100108 );
101109 return ;
102110 } else {
0 commit comments