From 2c4dbba9111184299cba2935b26b23011566ee65 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 12 Dec 2015 21:21:17 +0200 Subject: [PATCH 001/182] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000000..7f0b245ab6b1e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Login-As-Customer-for-Magento-2 +Allows admin to login as a customer (enter to customer account). From dd15e184efe63d3fa5ebdf6d7906ef5874b5fdf2 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 12 Dec 2015 21:26:13 +0200 Subject: [PATCH 002/182] Initial commit --- .../Block/Adminhtml/Customer/Edit/Login.php | 68 ++++++ .../LoginAsCustomer/Block/Adminhtml/Login.php | 26 +++ .../Adminhtml/System/Config/Form/Info.php | 52 +++++ .../Controller/Adminhtml/Login/Grid.php | 36 ++++ .../Controller/Adminhtml/Login/Index.php | 49 +++++ .../Controller/Adminhtml/Login/Login.php | 58 +++++ .../Controller/Login/Index.php | 65 ++++++ app/code/Magefan/LoginAsCustomer/LICENSE.txt | 48 +++++ .../Model/AdminNotificationFeed.php | 170 +++++++++++++++ .../Magefan/LoginAsCustomer/Model/Login.php | 201 ++++++++++++++++++ .../Model/ResourceModel/Login.php | 27 +++ .../Model/ResourceModel/Login/Collection.php | 28 +++ .../ResourceModel/Login/Grid/Collection.php | 49 +++++ ...redispathAdminActionControllerObserver.php | 55 +++++ app/code/Magefan/LoginAsCustomer/README.md | 1 + .../LoginAsCustomer/Setup/InstallSchema.php | 86 ++++++++ .../Magefan/LoginAsCustomer/composer.json | 21 ++ app/code/Magefan/LoginAsCustomer/etc/acl.xml | 30 +++ .../LoginAsCustomer/etc/adminhtml/events.xml | 14 ++ .../LoginAsCustomer/etc/adminhtml/menu.xml | 14 ++ .../LoginAsCustomer/etc/adminhtml/routes.xml | 16 ++ .../LoginAsCustomer/etc/adminhtml/system.xml | 28 +++ .../LoginAsCustomer/etc/frontend/routes.xml | 16 ++ .../Magefan/LoginAsCustomer/etc/module.xml | 16 ++ .../Magefan/LoginAsCustomer/registration.php | 13 ++ .../layout/loginascustomer_login_grid.xml | 16 ++ .../loginascustomer_login_grid_block.xml | 76 +++++++ .../layout/loginascustomer_login_index.xml | 18 ++ .../adminhtml/ui_component/customer_form.xml | 16 ++ 29 files changed, 1313 insertions(+) create mode 100755 app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php create mode 100755 app/code/Magefan/LoginAsCustomer/LICENSE.txt create mode 100755 app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php create mode 100755 app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php create mode 100755 app/code/Magefan/LoginAsCustomer/README.md create mode 100755 app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php create mode 100755 app/code/Magefan/LoginAsCustomer/composer.json create mode 100755 app/code/Magefan/LoginAsCustomer/etc/acl.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/module.xml create mode 100755 app/code/Magefan/LoginAsCustomer/registration.php create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php new file mode 100755 index 0000000000000..fd184e8be3de1 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php @@ -0,0 +1,68 @@ +_authorization = $authorization; + } + + /** + * @return array + */ + public function getButtonData() + { + $customerId = $this->getCustomerId(); + $data = []; + $canModify = $customerId && $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + if ($canModify) { + $data = [ + 'label' => __('Login As Customer'), + 'class' => 'login login-button', + 'on_click' => 'window.open( \'' . $this->getInvalidateTokenUrl() . + '\')', + 'sort_order' => 70, + ]; + } + return $data; + } + + /** + * @return string + */ + public function getInvalidateTokenUrl() + { + return $this->getUrl('loginascustomer/login/login', ['customer_id' => $this->getCustomerId()]); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php new file mode 100755 index 0000000000000..50216154da702 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php @@ -0,0 +1,26 @@ +removeButton('add'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php new file mode 100755 index 0000000000000..ef7a8ed8cccf7 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php @@ -0,0 +1,52 @@ +moduleList = $moduleList; + } + + /** + * Return info block html + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @return string + */ + public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + { + $m = $this->moduleList->getOne($this->getModuleName()); + $html = '
+ Login As Customer Extension v' . $m['setup_version'] . ' was developed by MageFan. +
'; + + return $html; + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php new file mode 100755 index 0000000000000..d8182e2536a67 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php @@ -0,0 +1,36 @@ +_view->loadLayout(false); + $this->_view->renderLayout(); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php new file mode 100755 index 0000000000000..515fdcbbd4517 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php @@ -0,0 +1,49 @@ +getRequest()->getParam('ajax')) { + $this->_forward('grid'); + return; + } + + $this->_objectManager + ->create('\Magefan\LoginAsCustomer\Model\Login') + ->deleteNotUsed(); + + $this->_view->loadLayout(); + $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); + $title = __('Login As Customer Log '); + $this->_view->getPage()->getConfig()->getTitle()->prepend($title); + $this->_addBreadcrumb($title, $title); + $this->_view->renderLayout(); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php new file mode 100755 index 0000000000000..84856552f4b44 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php @@ -0,0 +1,58 @@ +getRequest()->getParam('customer_id'); + + $login = $this->_objectManager + ->create('\Magefan\LoginAsCustomer\Model\Login') + ->setCustomerId($customerId); + + $login->deleteNotUsed(); + + $customer = $login->getCustomer(); + + if (!$customer->getId()) { + $this->messageManager->addError(__('Customer with this ID are no longer exist.')); + $this->_redirect('customer/index/index'); + return; + } + + $user = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); + $login->generate($user->getId()); + + $redirectUrl = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') + ->getStore($customer->getStoreId()) + ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret()]); + + $this->getResponse()->setRedirect($redirectUrl); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php b/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php new file mode 100755 index 0000000000000..f03be149ad8bf --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php @@ -0,0 +1,65 @@ +_initLogin(); + if (!$login) { + $this->_redirect('/'); + return; + } + + try { + $login->authenticateCustomer(); + } catch (Exception $e) { + $this->messageManager->addError($e->getMessage()); + } + + $this->messageManager->addSuccess( + __('You are logged in as customer: %1', $login->getCustomer()->getName()) + ); + + $this->_redirect('customer/account'); + } + + /** + * Init login info + * @return false || \Magefan\LoginAsCustomer\Model\Login + */ + protected function _initLogin() + { + $secret = $this->getRequest()->getParam('secret'); + if (!$secret) { + $this->messageManager->addError(__('Cannot login to account. No secret key provided.')); + return false; + } + + $login = $this->_objectManager + ->create('\Magefan\LoginAsCustomer\Model\Login') + ->loadNotUsed($secret); + + if ($login->getId()) { + return $login; + } else { + $this->messageManager->addError(__('Cannot login to account. Secret key is not valid.')); + return false; + } + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/LICENSE.txt b/app/code/Magefan/LoginAsCustomer/LICENSE.txt new file mode 100755 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php b/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php new file mode 100755 index 0000000000000..9e2125551ae71 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php @@ -0,0 +1,170 @@ +_backendAuthSession = $backendAuthSession; + $this->_moduleList = $moduleList; + $this->_moduleManager = $moduleManager; + } + + /** + * Retrieve feed url + * + * @return string + */ + public function getFeedUrl() + { + if (is_null($this->_feedUrl)) { + $this->_feedUrl = 'http://mage'.'fan' + .'.c'.'om/community/notifications'.'/'.'feed/'; + } + + $urlInfo = parse_url($this->urlBuilder->getBaseUrl()); + $domain = isset($urlInfo['host']) ? $urlInfo['host'] : ''; + + $url = $this->_feedUrl . 'domain/' . urlencode($domain); + + $modulesParams = array(); + foreach($this->getMagefanModules() as $key => $module) { + $key = str_replace('Magefan_', '', $key); + $modulesParams[] = $key . ',' . $module['setup_version']; + } + + if (count($modulesParams)) { + $url .= '/modules/'.base64_encode(implode(';', $modulesParams)); + } + + return $url; + } + + /** + * Get Magefan Modules Info + * + * @return $this + */ + protected function getMagefanModules() + { + $modules = array(); + foreach($this->_moduleList->getAll() as $moduleName => $module) { + if ( strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName) ) { + $modules[$moduleName] = $module; + } + } + + return $modules; + } + + /** + * Check feed for modification + * + * @return $this + */ + public function checkUpdate() + { + $session = $this->_backendAuthSession; + $time = time(); + $frequency = $this->getFrequency(); + if (($frequency + $session->getMfNoticeLastUpdate() > $time) + || ($frequency + $this->getLastUpdate() > $time) + ) { + return $this; + } + + $session->setMfNoticeLastUpdate($time); + return parent::checkUpdate(); + } + + /** + * Retrieve Update Frequency + * + * @return int + */ + public function getFrequency() + { + return 86400; + } + + /** + * Retrieve Last update time + * + * @return int + */ + public function getLastUpdate() + { + return $this->_cacheManager->load('magefan_admin_notifications_lastcheck'); + } + + /** + * Set last update time (now) + * + * @return $this + */ + public function setLastUpdate() + { + $this->_cacheManager->save(time(), 'magefan_admin_notifications_lastcheck'); + return $this; + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/Login.php b/app/code/Magefan/LoginAsCustomer/Model/Login.php new file mode 100755 index 0000000000000..58d02c0084474 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/Login.php @@ -0,0 +1,201 @@ +getEvent()->getObject() in this case + * + * @var string + */ + protected $_eventObject = 'loginascustomer_login'; + + /** + * @var \Magento\Customer\Model\CustomerFactory + */ + protected $_customerFactory; + + /** + * @var \Magento\Customer\Model\Customer + */ + protected $_customer; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $_eventManager; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime + */ + protected $_dateTime; + + /** + * @var \Magento\Framework\Math\Random + */ + protected $_random; + + /** + * Initialize dependencies. + * + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Store\Model\StoreManagerInterface $eventManager + * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime + * @param \Magento\Framework\Math\Random $random + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param array $data + */ + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Customer\Model\Session $customerSession, + \Magento\Store\Model\StoreManagerInterface $eventManager, + \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, + \Magento\Framework\Math\Random $random, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, + array $data = [] + ) { + $this->_customerFactory = $customerFactory; + $this->_customerSession = $customerSession; + $this->_eventManager = $eventManager; + $this->_dateTime = $dateTime; + $this->_random = $random; + parent::__construct($context, $registry, $resource, $resourceCollection, $data); + } + + /** + * Initialize resource model + * + * @return void + */ + protected function _construct() + { + $this->_init('Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + } + + /** + * Retrieve not used admin login + * @param string $secret + * @return self + */ + public function loadNotUsed($secret) + { + return $this->getCollection() + ->addFieldToFilter('secret', $secret) + ->addFieldToFilter('used', 0) + ->addFieldToFilter('created_at', ['gt' => $this->getDateTimePoint()]) + ->setPageSize(1) + ->getFirstItem(); + } + + /** + * Delete not used credentials + * @return void + */ + public function deleteNotUsed() + { + $resource = $this->getResource(); + $resource->getConnection()->delete( + $resource->getTable('magefan_login_as_customer'), [ + 'created_at < ?' => $this->getDateTimePoint(), + 'used = ?' => 0, + ] + ); + } + + /** + * Retrieve login datetime point + * @return [type] [description] + */ + protected function getDateTimePoint() + { + return date('Y-m-d H:i:s', $this->_dateTime->gmtTimestamp() - self::TIME_FRAME); + } + + /** + * Retrieve customer + * @return \Magento\Customer\Model\Customer + */ + public function getCustomer() + { + if (is_null($this->_customer)) { + $this->_customer = $this->_customerFactory->create() + ->load($this->getCustomerId()); + } + return $this->_customer; + } + + /** + * Login Customer + * @return false || \Magento\Customer\Model\Customer + */ + public function authenticateCustomer() + { + $customer = $this->getCustomer(); + + if (!$customer->getId()) { + throw new Exception(__("Customer are no longer exist."), 1); + } + + $this->_eventManager->dispatch('customer_data_object_login', ['customer' => $customer]); + + $this->_customerSession->loginById($customer->getId()); + $this->_customerSession->regenerateId(); + + $this->setUsed(1)->save(); + + return $customer; + } + + /** + * Generate new login credentials + * @param int $adminId + * @return $this + */ + public function generate($adminId) + { + return $this->setData([ + 'customer_id' => $this->getCustomerId(), + 'admin_id' => $adminId, + 'secret' => $this->_random->getRandomString(64), + 'used' => 0, + 'created_at' => $this->_dateTime->gmtTimestamp(), + ])->save(); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php new file mode 100755 index 0000000000000..0902b2b6c8ace --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php @@ -0,0 +1,27 @@ +_init('magefan_login_as_customer', 'login_id'); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php new file mode 100755 index 0000000000000..25f6d5da09445 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php @@ -0,0 +1,28 @@ +_init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php new file mode 100755 index 0000000000000..79b5f4b7b0567 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php @@ -0,0 +1,49 @@ +_map['fields']['email'] = 'c.email'; + } + + /** + * Init collection select + * + * @return $this + */ + protected function _initSelect() + { + parent::_initSelect(); + $this->getSelect() + ->joinLeft( + array('c' => $this->getTable('customer_entity')), + 'c.entity_id = main_table.customer_id', + array('email') + )->joinLeft( + array('a' => $this->getTable('admin_user')), + 'a.user_id = main_table.admin_id', + array('username') + ); + return $this; + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php b/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php new file mode 100755 index 0000000000000..d89dd247d60c1 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php @@ -0,0 +1,55 @@ +_feedFactory = $feedFactory; + $this->_backendAuthSession = $backendAuthSession; + } + + /** + * Predispath admin action controller + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + if ($this->_backendAuthSession->isLoggedIn()) { + $feedModel = $this->_feedFactory->create(); + /* @var $feedModel \Magefan\LoginAsCustomer\Model\AdminNotificationFeed */ + $feedModel->checkUpdate(); + } + } +} diff --git a/app/code/Magefan/LoginAsCustomer/README.md b/app/code/Magefan/LoginAsCustomer/README.md new file mode 100755 index 0000000000000..fcc244e87213a --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/README.md @@ -0,0 +1 @@ +The Magefan_LoginAsCustomer implements allow to admins login as customer. \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php b/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php new file mode 100755 index 0000000000000..a802c3d5e8c2f --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php @@ -0,0 +1,86 @@ +startSetup(); + + /** + * Create table 'magefan_login_as_customer' + */ + $table = $installer->getConnection()->newTable( + $installer->getTable('magefan_login_as_customer') + )->addColumn( + 'login_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['identity' => true, 'nullable' => false, 'primary' => true], + 'Admin Login ID' + )->addColumn( + 'customer_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => true], + 'Customer ID' + )->addColumn( + 'admin_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => true], + 'Admin ID' + )->addColumn( + 'secret', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + '64', + ['nullable' => true], + 'Login Secret' + )->addColumn( + 'used', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + ['nullable' => false, 'default' => '1'], + 'Is Login Used' + )->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + [], + 'Creation Time' + )->addIndex( + $installer->getIdxName('magefan_login_as_customer', ['customer_id']), + ['customer_id'] + ) + ->addIndex( + $installer->getIdxName('magefan_login_as_customer', ['admin_id']), + ['admin_id'] + )->setComment( + 'Magefan Login As Customer Table' + ); + $installer->getConnection()->createTable($table); + + $installer->endSetup(); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/composer.json b/app/code/Magefan/LoginAsCustomer/composer.json new file mode 100755 index 0000000000000..e6875b595dcfa --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/composer.json @@ -0,0 +1,21 @@ +{ + "name": "magefan/module-loginascustomer", + "description": "N/A", + "require": { + "php": "~5.5.0|~5.6.0|~7.0.0", + "magento/module-customer": "100.0.0", + "magento/framework": "100.0.0" + }, + "type": "magento2-module", + "version": "2.0.0", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ "registration.php" ], + "psr-4": { + "Magefan\\LoginAsCustomer\\": "" + } + } +} diff --git a/app/code/Magefan/LoginAsCustomer/etc/acl.xml b/app/code/Magefan/LoginAsCustomer/etc/acl.xml new file mode 100755 index 0000000000000..948f8f61ca801 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/acl.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml new file mode 100755 index 0000000000000..ecbc7cf570d4c --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml new file mode 100755 index 0000000000000..5a4b630dc5844 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml new file mode 100755 index 0000000000000..75d00df9b72a5 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml new file mode 100755 index 0000000000000..7a0d7ef443200 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml @@ -0,0 +1,28 @@ + + + + + + + +
+ separator-top + + magefan + Magefan_LoginAsCustomer::config_section + + + + Magefan\LoginAsCustomer\Block\Adminhtml\System\Config\Form\Info + + +
+
+
diff --git a/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml b/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml new file mode 100755 index 0000000000000..00b11bb15f560 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/etc/module.xml b/app/code/Magefan/LoginAsCustomer/etc/module.xml new file mode 100755 index 0000000000000..001e8e18ea990 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/module.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/registration.php b/app/code/Magefan/LoginAsCustomer/registration.php new file mode 100755 index 0000000000000..f8fc94bd8b290 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/registration.php @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml new file mode 100755 index 0000000000000..aba5c109be8f5 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml @@ -0,0 +1,76 @@ + + + + + + + + subscriberGrid + Magefan\LoginAsCustomer\Model\ResourceModel\Login\Grid\Collection + created_at + desc + 1 + + + + + + ID + login_id + col-id + col-id + + + + + Customer ID + customer_id + col-title + col-title + + + + + Customer Email + email + col-title + col-title + + + + + Admin ID + admin_id + col-title + col-title + + + + + Admin Name + username + col-title + col-title + + + + + Logged In + created_at + datetime + col-first-name + col-first-name + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml new file mode 100755 index 0000000000000..471d96ee418bd --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml b/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml new file mode 100755 index 0000000000000..a5975968b23bf --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml @@ -0,0 +1,16 @@ + + +
+ + + Magefan\LoginAsCustomer\Block\Adminhtml\Customer\Edit\Login + + +
From 09c2e9be62fd5ff844b3086fea6fdf5b64325a6d Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 26 Mar 2016 10:42:17 +0200 Subject: [PATCH 003/182] Fix error during compilation --- .../LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php index fd184e8be3de1..429dad71eec8c 100755 --- a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php @@ -30,11 +30,10 @@ class Login extends GenericButton implements ButtonProviderInterface */ public function __construct( \Magento\Backend\Block\Widget\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\AuthorizationInterface $authorization + \Magento\Framework\Registry $registry ) { parent::__construct($context, $registry); - $this->_authorization = $authorization; + $this->_authorization = $context->getAuthorization(); } /** From 8c2fb35a0ff87305b72da0b305b85079bd152a4d Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 2 Jun 2016 21:56:15 +0300 Subject: [PATCH 004/182] Move project to root --- .../Block => Block}/Adminhtml/Customer/Edit/Login.php | 0 .../Magefan/LoginAsCustomer/Block => Block}/Adminhtml/Login.php | 0 .../Block => Block}/Adminhtml/System/Config/Form/Info.php | 0 .../Controller => Controller}/Adminhtml/Login/Grid.php | 0 .../Controller => Controller}/Adminhtml/Login/Index.php | 0 .../Controller => Controller}/Adminhtml/Login/Login.php | 0 .../LoginAsCustomer/Controller => Controller}/Login/Index.php | 0 app/code/Magefan/LoginAsCustomer/LICENSE.txt => LICENSE.txt | 0 .../LoginAsCustomer/Model => Model}/AdminNotificationFeed.php | 0 {app/code/Magefan/LoginAsCustomer/Model => Model}/Login.php | 0 .../LoginAsCustomer/Model => Model}/ResourceModel/Login.php | 0 .../Model => Model}/ResourceModel/Login/Collection.php | 0 .../Model => Model}/ResourceModel/Login/Grid/Collection.php | 0 .../PredispathAdminActionControllerObserver.php | 0 .../Magefan/LoginAsCustomer/Setup => Setup}/InstallSchema.php | 0 app/code/Magefan/LoginAsCustomer/README.md | 1 - app/code/Magefan/LoginAsCustomer/composer.json => composer.json | 0 {app/code/Magefan/LoginAsCustomer/etc => etc}/acl.xml | 0 .../Magefan/LoginAsCustomer/etc => etc}/adminhtml/events.xml | 0 {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/menu.xml | 0 .../Magefan/LoginAsCustomer/etc => etc}/adminhtml/routes.xml | 0 .../Magefan/LoginAsCustomer/etc => etc}/adminhtml/system.xml | 0 .../code/Magefan/LoginAsCustomer/etc => etc}/frontend/routes.xml | 0 {app/code/Magefan/LoginAsCustomer/etc => etc}/module.xml | 0 .../Magefan/LoginAsCustomer/registration.php => registration.php | 0 .../adminhtml/layout/loginascustomer_login_grid.xml | 0 .../adminhtml/layout/loginascustomer_login_grid_block.xml | 0 .../adminhtml/layout/loginascustomer_login_index.xml | 0 .../view => view}/adminhtml/ui_component/customer_form.xml | 0 29 files changed, 1 deletion(-) rename {app/code/Magefan/LoginAsCustomer/Block => Block}/Adminhtml/Customer/Edit/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Block => Block}/Adminhtml/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Block => Block}/Adminhtml/System/Config/Form/Info.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Adminhtml/Login/Grid.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Adminhtml/Login/Index.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Adminhtml/Login/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Login/Index.php (100%) rename app/code/Magefan/LoginAsCustomer/LICENSE.txt => LICENSE.txt (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/AdminNotificationFeed.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/ResourceModel/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/ResourceModel/Login/Collection.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/ResourceModel/Login/Grid/Collection.php (100%) rename {app/code/Magefan/LoginAsCustomer/Observer => Observer}/PredispathAdminActionControllerObserver.php (100%) rename {app/code/Magefan/LoginAsCustomer/Setup => Setup}/InstallSchema.php (100%) delete mode 100755 app/code/Magefan/LoginAsCustomer/README.md rename app/code/Magefan/LoginAsCustomer/composer.json => composer.json (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/acl.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/events.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/menu.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/routes.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/system.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/frontend/routes.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/module.xml (100%) rename app/code/Magefan/LoginAsCustomer/registration.php => registration.php (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/layout/loginascustomer_login_grid.xml (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/layout/loginascustomer_login_grid_block.xml (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/layout/loginascustomer_login_index.xml (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/ui_component/customer_form.xml (100%) diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/Block/Adminhtml/Customer/Edit/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php rename to Block/Adminhtml/Customer/Edit/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php b/Block/Adminhtml/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php rename to Block/Adminhtml/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php rename to Block/Adminhtml/System/Config/Form/Info.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php b/Controller/Adminhtml/Login/Grid.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php rename to Controller/Adminhtml/Login/Grid.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php rename to Controller/Adminhtml/Login/Index.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php rename to Controller/Adminhtml/Login/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php b/Controller/Login/Index.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php rename to Controller/Login/Index.php diff --git a/app/code/Magefan/LoginAsCustomer/LICENSE.txt b/LICENSE.txt similarity index 100% rename from app/code/Magefan/LoginAsCustomer/LICENSE.txt rename to LICENSE.txt diff --git a/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php rename to Model/AdminNotificationFeed.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/Login.php b/Model/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/Login.php rename to Model/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php b/Model/ResourceModel/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php rename to Model/ResourceModel/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php b/Model/ResourceModel/Login/Collection.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php rename to Model/ResourceModel/Login/Collection.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php rename to Model/ResourceModel/Login/Grid/Collection.php diff --git a/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php b/Observer/PredispathAdminActionControllerObserver.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php rename to Observer/PredispathAdminActionControllerObserver.php diff --git a/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php b/Setup/InstallSchema.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php rename to Setup/InstallSchema.php diff --git a/app/code/Magefan/LoginAsCustomer/README.md b/app/code/Magefan/LoginAsCustomer/README.md deleted file mode 100755 index fcc244e87213a..0000000000000 --- a/app/code/Magefan/LoginAsCustomer/README.md +++ /dev/null @@ -1 +0,0 @@ -The Magefan_LoginAsCustomer implements allow to admins login as customer. \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/composer.json b/composer.json similarity index 100% rename from app/code/Magefan/LoginAsCustomer/composer.json rename to composer.json diff --git a/app/code/Magefan/LoginAsCustomer/etc/acl.xml b/etc/acl.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/acl.xml rename to etc/acl.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml b/etc/adminhtml/events.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml rename to etc/adminhtml/events.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml rename to etc/adminhtml/menu.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml rename to etc/adminhtml/routes.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml b/etc/adminhtml/system.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml rename to etc/adminhtml/system.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml b/etc/frontend/routes.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml rename to etc/frontend/routes.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/module.xml b/etc/module.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/module.xml rename to etc/module.xml diff --git a/app/code/Magefan/LoginAsCustomer/registration.php b/registration.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/registration.php rename to registration.php diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml b/view/adminhtml/layout/loginascustomer_login_grid.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml rename to view/adminhtml/layout/loginascustomer_login_grid.xml diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml b/view/adminhtml/layout/loginascustomer_login_grid_block.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml rename to view/adminhtml/layout/loginascustomer_login_grid_block.xml diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml b/view/adminhtml/layout/loginascustomer_login_index.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml rename to view/adminhtml/layout/loginascustomer_login_index.xml diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml b/view/adminhtml/ui_component/customer_form.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml rename to view/adminhtml/ui_component/customer_form.xml From 148a0629ee122cca83d55866852a3eed629225f6 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 2 Jun 2016 22:01:52 +0300 Subject: [PATCH 005/182] Change composer.json --- composer.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/composer.json b/composer.json index e6875b595dcfa..baa9b1d03dccb 100755 --- a/composer.json +++ b/composer.json @@ -1,11 +1,6 @@ { - "name": "magefan/module-loginascustomer", + "name": "magefan/module-login-as-customer", "description": "N/A", - "require": { - "php": "~5.5.0|~5.6.0|~7.0.0", - "magento/module-customer": "100.0.0", - "magento/framework": "100.0.0" - }, "type": "magento2-module", "version": "2.0.0", "license": [ From ea534dfc8314efddd5d04f1dff1b4fb52744c01e Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 2 Jun 2016 22:48:39 +0300 Subject: [PATCH 006/182] Fix issue: after login as customer admin session expire --- Controller/Adminhtml/Login/Login.php | 16 ++++++++-------- Model/Login.php | 14 +++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 84856552f4b44..59f23603a6a18 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -13,14 +13,14 @@ */ class Login extends \Magento\Backend\App\Action { - /** + /** * Login as customer action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { - $customerId = (int) $this->getRequest()->getParam('customer_id'); + $customerId = (int) $this->getRequest()->getParam('customer_id'); $login = $this->_objectManager ->create('\Magefan\LoginAsCustomer\Model\Login') @@ -30,18 +30,18 @@ public function execute() $customer = $login->getCustomer(); - if (!$customer->getId()) { - $this->messageManager->addError(__('Customer with this ID are no longer exist.')); - $this->_redirect('customer/index/index'); - return; - } + if (!$customer->getId()) { + $this->messageManager->addError(__('Customer with this ID are no longer exist.')); + $this->_redirect('customer/index/index'); + return; + } $user = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); $login->generate($user->getId()); $redirectUrl = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') ->getStore($customer->getStoreId()) - ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret()]); + ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); $this->getResponse()->setRedirect($redirectUrl); } diff --git a/Model/Login.php b/Model/Login.php index 58d02c0084474..cbfb9a02955f4 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -44,10 +44,6 @@ class Login extends \Magento\Framework\Model\AbstractModel */ protected $_customer; - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_eventManager; /** * @var \Magento\Customer\Model\Session @@ -71,7 +67,6 @@ class Login extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $eventManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime * @param \Magento\Framework\Math\Random $random * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource @@ -83,7 +78,6 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Store\Model\StoreManagerInterface $eventManager, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, \Magento\Framework\Math\Random $random, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, @@ -92,7 +86,6 @@ public function __construct( ) { $this->_customerFactory = $customerFactory; $this->_customerSession = $customerSession; - $this->_eventManager = $eventManager; $this->_dateTime = $dateTime; $this->_random = $random; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -172,10 +165,9 @@ public function authenticateCustomer() throw new Exception(__("Customer are no longer exist."), 1); } - $this->_eventManager->dispatch('customer_data_object_login', ['customer' => $customer]); - - $this->_customerSession->loginById($customer->getId()); - $this->_customerSession->regenerateId(); + if ($this->_customerSession->loginById($customer->getId())) { + $this->_customerSession->regenerateId(); + } $this->setUsed(1)->save(); From 0af073e1319c65c643ce6a359af079fb685c8248 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 4 Jun 2016 11:15:30 +0300 Subject: [PATCH 007/182] Up version to 2.0.1 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index baa9b1d03dccb..f756fef698590 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magefan/module-login-as-customer", "description": "N/A", "type": "magento2-module", - "version": "2.0.0", + "version": "2.0.1", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 001e8e18ea990..94fd8a5dede01 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 3dabd5c3b3c5da55ae1b1d466701fa98e1d7b1cb Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 9 Jun 2016 23:56:01 +0300 Subject: [PATCH 008/182] Fix issue: customer data is not updated after login --- Controller/Login/Index.php | 4 +-- Controller/Login/Post.php | 25 ++++++++++++++++++ Controller/Login/Proceed.php | 26 +++++++++++++++++++ etc/frontend/sections.xml | 13 ++++++++++ .../layout/loginascustomer_login_proceed.xml | 21 +++++++++++++++ view/frontend/templates/login.phtml | 22 ++++++++++++++++ 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100755 Controller/Login/Post.php create mode 100755 Controller/Login/Proceed.php create mode 100644 etc/frontend/sections.xml create mode 100644 view/frontend/layout/loginascustomer_login_proceed.xml create mode 100644 view/frontend/templates/login.phtml diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index f03be149ad8bf..e8d1cf7eb19c7 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -1,6 +1,6 @@ getCustomer()->getName()) ); - $this->_redirect('customer/account'); + $this->_redirect('*/*/proceed'); } /** diff --git a/Controller/Login/Post.php b/Controller/Login/Post.php new file mode 100755 index 0000000000000..d6b144eacd301 --- /dev/null +++ b/Controller/Login/Post.php @@ -0,0 +1,25 @@ +_redirect('customer/account'); + } + +} diff --git a/Controller/Login/Proceed.php b/Controller/Login/Proceed.php new file mode 100755 index 0000000000000..a78108c163113 --- /dev/null +++ b/Controller/Login/Proceed.php @@ -0,0 +1,26 @@ +_view->loadLayout(); + $this->_view->renderLayout(); + } + +} diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml new file mode 100644 index 0000000000000..e3569fb0a914e --- /dev/null +++ b/etc/frontend/sections.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/view/frontend/layout/loginascustomer_login_proceed.xml b/view/frontend/layout/loginascustomer_login_proceed.xml new file mode 100644 index 0000000000000..78da65f40ea6d --- /dev/null +++ b/view/frontend/layout/loginascustomer_login_proceed.xml @@ -0,0 +1,21 @@ + + + + + + + You are logged in. + + + + + + + \ No newline at end of file diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml new file mode 100644 index 0000000000000..263edc462de17 --- /dev/null +++ b/view/frontend/templates/login.phtml @@ -0,0 +1,22 @@ + +

+
+ +
+ From fba97888de81bc1df017d9c56dfe5efcd3ba5098 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 14 Jun 2016 22:47:24 +0300 Subject: [PATCH 009/182] Hide button until waiting login --- view/frontend/templates/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml index 263edc462de17..0ffc6c83dc7df 100644 --- a/view/frontend/templates/login.phtml +++ b/view/frontend/templates/login.phtml @@ -8,7 +8,7 @@ ?>

- +
diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js deleted file mode 100644 index 7ffb6515b5e46..0000000000000 --- a/app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'underscore', - 'jquery', - 'uiComponent', - 'domReady!' -], function (_, $, Component) { - 'use strict'; - - return Component.extend({ - - defaults: { - clientConfig: { - - checkoutInited: false, - - /** - * @param {Object} event - */ - click: function (event) { - $('body').trigger('processStart'); - - event.preventDefault(); - - if (!this.clientConfig.checkoutInited) { - this.clientConfig.checkoutInited = true; - } - } - } - }, - - /** - * @returns {Object} - */ - initialize: function () { - this._super(); - - return this.initClient(); - }, - - /** - * @returns {Object} - */ - initClient: function () { - _.each(this.clientConfig, function (fn, name) { - if (typeof fn === 'function') { - this.clientConfig[name] = fn.bind(this); - } - }, this); - - return this; - } - }); -}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js deleted file mode 100644 index 0420256e20ef5..0000000000000 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -/* eslint-disable max-nested-callbacks */ -define([ - 'squire', - 'jquery' -], function (Squire, $) { - 'use strict'; - - describe('Magento_Paypal/js/in-context/express-checkout', function () { - - var model, - event, - paypalExpressCheckout, - injector = new Squire(), - mocks = { - 'paypalInContextExpressCheckout': { - checkout: jasmine.createSpyObj('checkout', - ['setup', 'initXO', 'startFlow', 'closeFlow'] - ) - }, - 'Magento_Customer/js/customer-data': { - set: jasmine.createSpy(), - invalidate: jasmine.createSpy() - } - }; - - /** - * Run before each test method - * - * @return void - */ - beforeEach(function (done) { - event = { - /** Stub */ - preventDefault: jasmine.createSpy('preventDefault') - }; - - injector.mock(mocks); - - injector.require([ - 'paypalInContextExpressCheckout', - 'Magento_Paypal/js/in-context/express-checkout'], function (PayPal, Constr) { - paypalExpressCheckout = PayPal; - model = new Constr(); - - done(); - }); - }); - - afterEach(function () { - try { - injector.clean(); - injector.remove(); - } catch (e) {} - }); - - describe('clientConfig.click method', function () { - - it('Check for properties defined ', function () { - expect(model.hasOwnProperty('clientConfig')).toBeDefined(); - expect(model.clientConfig.hasOwnProperty('click')).toBeDefined(); - expect(model.clientConfig.hasOwnProperty('checkoutInited')).toBeDefined(); - }); - - it('Check properties type', function () { - expect(typeof model.clientConfig.checkoutInited).toEqual('boolean'); - expect(typeof model.clientConfig.click).toEqual('function'); - }); - - it('Check properties value', function () { - expect(model.clientConfig.checkoutInited).toEqual(false); - }); - - it('Check call "click" method', function () { - - spyOn(jQuery.fn, 'trigger'); - spyOn(jQuery, 'get').and.callFake(function () { - var d = $.Deferred(); - - d.resolve({ - 'url': true - }); - - return d.promise(); - }); - - model.clientConfig.click(event); - - expect(event.preventDefault).toHaveBeenCalled(); - expect(paypalExpressCheckout.checkout.initXO).toHaveBeenCalled(); - expect(model.clientConfig.checkoutInited).toEqual(true); - expect(jQuery.get).toHaveBeenCalled(); - expect(jQuery('body').trigger).toHaveBeenCalledWith( - jasmine.arrayContaining(['processStart'], ['processStop']) - ); - }); - - it('Check call "click" method', function () { - var message = { - text: 'text', - type: 'error' - }; - - spyOn(jQuery.fn, 'trigger'); - spyOn(jQuery, 'get').and.callFake(function () { - var d = $.Deferred(); - - d.resolve({ - message: message - }); - - return d.promise(); - }); - - model.clientConfig.click(event); - expect(mocks['Magento_Customer/js/customer-data'].set).toHaveBeenCalledWith('messages', { - messages: [message] - }); - expect(event.preventDefault).toHaveBeenCalled(); - expect(paypalExpressCheckout.checkout.initXO).toHaveBeenCalled(); - expect(model.clientConfig.checkoutInited).toEqual(true); - expect(jQuery.get).toHaveBeenCalled(); - expect(jQuery('body').trigger).toHaveBeenCalledWith( - jasmine.arrayContaining(['processStart'], ['processStop']) - ); - }); - }); - }); -}); From d102b9ed83498b4deaac0163ee2c51e35fbfd97f Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Wed, 28 Jun 2017 20:53:37 +0300 Subject: [PATCH 024/182] Up version to 2.1.2 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 01f8aab441a2f..41fb373ef8e88 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magefan/module-login-as-customer", "description": "N/A", "type": "magento2-module", - "version": "2.1.1", + "version": "2.1.2", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 10903262b9542..1143d72738835 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 0ebb4ff86ac8c6c47ccbd92b0f9f0d51e8a2012d Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 28 Sep 2017 20:44:36 +0300 Subject: [PATCH 025/182] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f0b245ab6b1e..8c9ee4ce47beb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ -# Login-As-Customer-for-Magento-2 +# [Magento 2 Login As Customer](https://magefan.com/login-as-customer-magento-2-extension) by Magefan + Allows admin to login as a customer (enter to customer account). + +## Requirements + * Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x + +## Installation Method 1 - Installing via composer + * Open command line + * Using command "cd" navigate to your magento2 root directory + * Run command: composer require magefan/module-login-as-customer + + + +## Installation Method 2 - Installing using archive + * Download [ZIP Archive](https://github.com/magefan/module-login-as-customer/archive/master.zip) + * Extract files + * In your Magento 2 root directory create folder app/code/Magefan/LoginAsCustomer + * Copy files and folders from archive to that folder + * In command line, using "cd", navigate to your Magento 2 root directory + * Run commands: +``` +php bin/magento setup:upgrade +php bin/magento setup:di:compile +php bin/magento setup:static-content:deploy +``` + +## Support +If you have any issues, please [contact us](mailto:support@magefan.com) +then if you still need help, open a bug report in GitHub's +[issue tracker](https://github.com/magefan/module-login-as-customer/issues). + +Please do not use Magento Marketplace Reviews or (especially) the Q&A for support. +There isn't a way for us to reply to reviews and the Q&A moderation is very slow. + +## Need More Features? +Please contact us to get a quote +https://magefan.com/contact + +## License +The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). From 3443504cfd389dcf6772e38d89adaa8067ee32bc Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Fri, 6 Oct 2017 23:22:34 +0300 Subject: [PATCH 026/182] Added php requirements --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 41fb373ef8e88..a4a43a41decd0 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,9 @@ { "name": "magefan/module-login-as-customer", "description": "N/A", + "require": { + "php": "~5.6.5|7.0.2|7.0.4|~7.0.6|7.1.0|7.1.1|7.1.2|7.1.3|7.1.4|7.1.5|7.1.6|7.1.7|7.1.8|7.1.9" + }, "type": "magento2-module", "version": "2.1.2", "license": [ From b76c8c9c684ac073fd40bfd7ecd0f1b5177955a4 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Fri, 13 Oct 2017 13:25:58 +0300 Subject: [PATCH 027/182] Fix for Issue #4 --- Controller/Login/Index.php | 14 -------------- Model/Login.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 2e7a462cc60a6..027d558105279 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -26,20 +26,6 @@ public function execute() } try { - $session = $this->_objectManager - ->create('\Magento\Customer\Model\Session'); - if ($session->getId()) { - /* Logout if logged in */ - $session->logout(); - } else { - /* Remove items from cart */ - $cart = $this->_objectManager - ->create('\Magento\Checkout\Model\Cart'); - foreach ($cart->getQuote()->getAllVisibleItems() as $item) { - $cart->removeItem($item->getId()); - } - $cart->save(); - } /* Log in */ $login->authenticateCustomer(); } catch (\Exception $e) { diff --git a/Model/Login.php b/Model/Login.php index e55f6a393c736..6ec2cb8dcf3d8 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -60,6 +60,11 @@ class Login extends \Magento\Framework\Model\AbstractModel */ protected $_random; + /** + * @var \Magento\Checkout\Model\Cart + */ + protected $cart; + /** * Initialize dependencies. * @@ -69,6 +74,7 @@ class Login extends \Magento\Framework\Model\AbstractModel * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime * @param \Magento\Framework\Math\Random $random + * @param \Magento\Checkout\Model\Cart $cart * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data @@ -80,6 +86,7 @@ public function __construct( \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, \Magento\Framework\Math\Random $random, + \Magento\Checkout\Model\Cart $cart, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] @@ -88,6 +95,7 @@ public function __construct( $this->_customerSession = $customerSession; $this->_dateTime = $dateTime; $this->_random = $random; + $this->cart = $cart; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -159,6 +167,17 @@ public function getCustomer() */ public function authenticateCustomer() { + if ($this->_customerSession->getId()) { + /* Logout if logged in */ + $this->_customerSession->logout(); + } else { + /* Remove items from guest cart */ + foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { + $this->cart->removeItem($item->getId()); + } + $this->cart->save(); + } + $customer = $this->getCustomer(); if (!$customer->getId()) { @@ -172,6 +191,15 @@ public function authenticateCustomer() ); } + /* Save quote */ + $this->cart->getQuote()->getBillingAddress(); + $this->cart->getQuote()->getShippingAddress(); + $this->cart->getQuote()->setCustomer($this->_customerSession->getCustomerDataObject()) + ->setCustomerGroupId($customer->getGroupId()) + ->setTotalsCollectedFlag(false) + ->collectTotals(); + $this->cart->getQuote()->save(); + $this->setUsed(1)->save(); return $customer; From a815c0b3b6182f8f8bdbe4493981c4369ee81a09 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 24 Oct 2017 10:33:59 +0300 Subject: [PATCH 028/182] Up version to 2.1.3 --- composer.json | 4 ++-- etc/module.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a4a43a41decd0..7abcae875e3ee 100755 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "N/A", "require": { - "php": "~5.6.5|7.0.2|7.0.4|~7.0.6|7.1.0|7.1.1|7.1.2|7.1.3|7.1.4|7.1.5|7.1.6|7.1.7|7.1.8|7.1.9" + "php": "~5.6.5 || >=7.0" }, "type": "magento2-module", - "version": "2.1.2", + "version": "2.1.3", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 1143d72738835..bc5e13e24835b 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From fa0142a9040a0e9e991f992a79bfc02c23d72e88 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 21 Nov 2017 10:17:13 +0200 Subject: [PATCH 029/182] Up version to 2.1.4 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7abcae875e3ee..e987f08e9f214 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~5.6.5 || >=7.0" }, "type": "magento2-module", - "version": "2.1.3", + "version": "2.1.4", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index bc5e13e24835b..5137e71b65983 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 22f53490b8a4602feb69b2e83e78387102dd6703 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 4 Apr 2020 11:00:32 +0700 Subject: [PATCH 030/182] login-as-customer/issues/59: Customer data not invalidated private content after logged in --- etc/frontend/sections.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml index e3569fb0a914e..e94b42ea04d5f 100644 --- a/etc/frontend/sections.xml +++ b/etc/frontend/sections.xml @@ -9,5 +9,11 @@ --> - + +
+
+
+
+
+ From 8d9746aa8f5ad9aef43e773331b6d669436e3c89 Mon Sep 17 00:00:00 2001 From: Andriy Martynovskyj Date: Fri, 23 Feb 2018 12:46:15 +0200 Subject: [PATCH 031/182] add button in order, ship, credit memo, invoice page --- Block/Adminhtml/Convert.php | 16 ++++ Block/Adminhtml/Customer/Edit/Login.php | 3 +- Block/Adminhtml/Login.php | 2 +- Controller/Adminhtml/Guest/Convert.php | 39 ++++++++ Controller/Adminhtml/Login/Grid.php | 2 +- Controller/Adminhtml/Login/Index.php | 2 +- Controller/Adminhtml/Login/Login.php | 2 +- Controller/Login/Index.php | 2 +- Controller/Login/Post.php | 2 +- Controller/Login/Proceed.php | 2 +- Model/AdminNotificationFeed.php | 2 +- Model/Login.php | 2 +- Model/PageCache/ConfigPlugin.php | 2 +- Model/ResourceModel/Login.php | 2 +- Model/ResourceModel/Login/Collection.php | 2 +- Model/ResourceModel/Login/Grid/Collection.php | 2 +- ...redispathAdminActionControllerObserver.php | 2 +- .../WbsiterestrictionFrontendObserver.php | 2 +- Plugin/Button/ToolbarPlugin.php | 89 +++++++++++++++++++ .../{Actions.php => AbstractColumn.php} | 49 ++++++---- .../Listing/Column/CustomerActions.php | 17 ++++ Ui/Component/Listing/Column/OrderActions.php | 15 ++++ composer.json | 2 +- etc/acl.xml | 4 +- etc/adminhtml/di.xml | 12 +++ etc/adminhtml/events.xml | 4 +- etc/adminhtml/menu.xml | 4 +- etc/adminhtml/routes.xml | 4 +- etc/adminhtml/system.xml | 4 +- etc/frontend/di.xml | 4 +- etc/frontend/events.xml | 4 +- etc/frontend/routes.xml | 4 +- etc/frontend/sections.xml | 4 +- etc/module.xml | 5 +- etc/webrestrictions.xml | 4 +- registration.php | 2 +- .../layout/loginascustomer_guest_convert.xml | 21 +++++ .../layout/loginascustomer_login_grid.xml | 2 +- .../loginascustomer_login_grid_block.xml | 2 +- .../layout/loginascustomer_login_index.xml | 2 +- view/adminhtml/templates/convert.phtml | 14 +++ view/adminhtml/ui_component/customer_form.xml | 2 +- .../ui_component/customer_listing.xml | 4 +- .../ui_component/sales_order_grid.xml | 21 +++++ view/frontend/templates/login.phtml | 2 +- 45 files changed, 314 insertions(+), 75 deletions(-) create mode 100644 Block/Adminhtml/Convert.php create mode 100644 Controller/Adminhtml/Guest/Convert.php create mode 100644 Plugin/Button/ToolbarPlugin.php rename Ui/Component/Listing/Column/{Actions.php => AbstractColumn.php} (57%) create mode 100644 Ui/Component/Listing/Column/CustomerActions.php create mode 100644 Ui/Component/Listing/Column/OrderActions.php create mode 100644 etc/adminhtml/di.xml create mode 100755 view/adminhtml/layout/loginascustomer_guest_convert.xml create mode 100644 view/adminhtml/templates/convert.phtml create mode 100644 view/adminhtml/ui_component/sales_order_grid.xml diff --git a/Block/Adminhtml/Convert.php b/Block/Adminhtml/Convert.php new file mode 100644 index 0000000000000..e932ebe571ea8 --- /dev/null +++ b/Block/Adminhtml/Convert.php @@ -0,0 +1,16 @@ +resultPageFactory = $resultPageFactory; + } + + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page + */ + public function execute() + { + return $resultPage = $this->resultPageFactory->create(); + } +} \ No newline at end of file diff --git a/Controller/Adminhtml/Login/Grid.php b/Controller/Adminhtml/Login/Grid.php index d8182e2536a67..08c84c13cfb59 100755 --- a/Controller/Adminhtml/Login/Grid.php +++ b/Controller/Adminhtml/Login/Grid.php @@ -1,6 +1,6 @@ authorization = $authorization; + } + + /** + * @param \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject + * @param \Magento\Framework\View\Element\AbstractBlock $context + * @param \Magento\Backend\Block\Widget\Button\ButtonList $buttonList + */ + public function beforePushButtons( + Interceptor $subject, + AbstractBlock $context, + ButtonList $buttonList + ) { + $order = false; + if ('sales_order_edit' == $context->getNameInLayout()) { + $order = $context->getOrder(); + } elseif ('sales_invoice_view' == $context->getNameInLayout()) { + $order = $context->getInvoice()->getOrder(); + } elseif ('sales_shipment_view' == $context->getNameInLayout()) { + $order = $context->getShipment()->getOrder(); + } elseif ('sales_creditmemo_view' == $context->getNameInLayout()) { + $order = $context->getCreditmemo()->getOrder(); + } + if ($order) { + if ($this->isAllowed()) { + if (!empty($order['customer_id'])) { + $buttonUrl = $context->getUrl('loginascustomer/login/login', [ + 'customer_id' => $order['customer_id'] + ]); + $buttonList->add( + 'guest_to_customer', + ['label' => __('Login As Customer'), 'onclick' => 'window.open(\'' . $buttonUrl . '\')', 'class' => 'reset'], + -1 + ); + } else { + $buttonUrl = $context->getUrl('loginascustomer/guest/convert'); + $buttonList->add( + 'guest_to_customer', + ['label' => __('Convert Guest to Customer'), 'onclick' => 'window.location=\'' . $buttonUrl . '\'', 'class' => 'reset'], + -1 + ); + } + } + } + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function isAllowed() + { + return $this->authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + } +} diff --git a/Ui/Component/Listing/Column/Actions.php b/Ui/Component/Listing/Column/AbstractColumn.php similarity index 57% rename from Ui/Component/Listing/Column/Actions.php rename to Ui/Component/Listing/Column/AbstractColumn.php index b1691b98f1997..0cc226057d45b 100644 --- a/Ui/Component/Listing/Column/Actions.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -1,10 +1,11 @@ _authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); foreach ($dataSource['data']['items'] as &$item) { - $item[$this->getData('name')]['edit'] = [ - 'href' => $this->urlBuilder->getUrl( - 'loginascustomer/login/login', - ['customer_id' => $item['entity_id']] - ), - 'label' => __('Login As Customer'), - 'hidden' => $hidden, - 'target' => '_blank', - ]; + if(!empty($item[$this->sourceColumnName])) { + $item[$this->getData('name')]['edit'] = [ + 'href' => $this->urlBuilder->getUrl( + 'loginascustomer/login/login', + ['customer_id' => $item[$this->sourceColumnName]] + ), + 'label' => __('Login As Customer'), + 'hidden' => $hidden, + 'target' => '_blank', + ]; + } else { + $item[$this->getData('name')]['edit'] = [ + 'href' => $this->urlBuilder->getUrl( + 'loginascustomer/guest/convert', + ['customer_id' => $item[$this->sourceColumnName]] + ), + 'label' => __('Convert Guest to Customer'), + 'hidden' => $hidden, + 'target' => '_blank', + ]; + } + } } return $dataSource; } -} +} \ No newline at end of file diff --git a/Ui/Component/Listing/Column/CustomerActions.php b/Ui/Component/Listing/Column/CustomerActions.php new file mode 100644 index 0000000000000..cd924a6fbe732 --- /dev/null +++ b/Ui/Component/Listing/Column/CustomerActions.php @@ -0,0 +1,17 @@ +=7.0" }, "type": "magento2-module", - "version": "2.1.4", + "version": "2.1.5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/acl.xml b/etc/acl.xml index 948f8f61ca801..5211a0f3c9c0c 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -1,10 +1,8 @@ diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml new file mode 100644 index 0000000000000..cfecb87ba930d --- /dev/null +++ b/etc/adminhtml/di.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml index ecbc7cf570d4c..5df1ee44f45bd 100755 --- a/etc/adminhtml/events.xml +++ b/etc/adminhtml/events.xml @@ -1,10 +1,8 @@ diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index 5a4b630dc5844..903f9daa9b4c2 100755 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -1,10 +1,8 @@ diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 75d00df9b72a5..3e4b8c7f93c58 100755 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -1,10 +1,8 @@ diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index aba04b3282c76..1fd36ef6eef49 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,10 +1,8 @@ diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index a05b1f2662593..f2bf3cee01665 100755 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,10 +1,8 @@ diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index 68d8edf3b73cf..ce39528d3479a 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -1,10 +1,8 @@ diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 00b11bb15f560..69fe2b3533006 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -1,10 +1,8 @@ diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml index e94b42ea04d5f..9191a043a4889 100644 --- a/etc/frontend/sections.xml +++ b/etc/frontend/sections.xml @@ -1,10 +1,8 @@ - + + diff --git a/etc/webrestrictions.xml b/etc/webrestrictions.xml index 2356c211cad6f..707c6627499bb 100644 --- a/etc/webrestrictions.xml +++ b/etc/webrestrictions.xml @@ -1,10 +1,8 @@ diff --git a/registration.php b/registration.php index f8fc94bd8b290..a2cca455c35fc 100755 --- a/registration.php +++ b/registration.php @@ -1,6 +1,6 @@ + + + + + Convert To Customer + + + + + + + + diff --git a/view/adminhtml/layout/loginascustomer_login_grid.xml b/view/adminhtml/layout/loginascustomer_login_grid.xml index c4294063bfd23..c2438f74b5321 100755 --- a/view/adminhtml/layout/loginascustomer_login_grid.xml +++ b/view/adminhtml/layout/loginascustomer_login_grid.xml @@ -1,7 +1,7 @@ +
+

Customer to Guest Magento Extension.'); ?>

+ +
\ No newline at end of file diff --git a/view/adminhtml/ui_component/customer_form.xml b/view/adminhtml/ui_component/customer_form.xml index a5975968b23bf..cca16e44b08a2 100755 --- a/view/adminhtml/ui_component/customer_form.xml +++ b/view/adminhtml/ui_component/customer_form.xml @@ -1,7 +1,7 @@ - + Login diff --git a/view/adminhtml/ui_component/sales_order_grid.xml b/view/adminhtml/ui_component/sales_order_grid.xml new file mode 100644 index 0000000000000..5925420d1804f --- /dev/null +++ b/view/adminhtml/ui_component/sales_order_grid.xml @@ -0,0 +1,21 @@ + + ++ + + + + Action II + entity_id + + + + + diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml index 0ffc6c83dc7df..0de223d43e745 100644 --- a/view/frontend/templates/login.phtml +++ b/view/frontend/templates/login.phtml @@ -1,6 +1,6 @@ Date: Tue, 6 Mar 2018 16:47:06 +0200 Subject: [PATCH 032/182] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 8c9ee4ce47beb..7cb5ac1bf8833 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,11 @@ https://magefan.com/contact ## License The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). + +## Other Magefan Extensions That Can Be Installed Via Composer + * [Magento 2 Auto Currency Switcher Extension](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country) + * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Conflict Detector Extension](https://magefan.com/magento2-conflict-detector) + * [Magento 2 Lazy Load Extension](https://github.com/magefan/module-lazyload) + * [Magento 2 Rocket JavaScript Extension](https://github.com/magefan/module-rocketjavascript) + * [Magento 2 CLI Extension](https://github.com/magefan/module-cli) From e547abbd2a7170452e01d55ed0aca1c592ab663b Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 1 Apr 2020 11:56:21 +0200 Subject: [PATCH 033/182] Update readme installation instructions --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7cb5ac1bf8833..eac8a1af32a9c 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,17 @@ Allows admin to login as a customer (enter to customer account). * Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x ## Installation Method 1 - Installing via composer - * Open command line - * Using command "cd" navigate to your magento2 root directory - * Run command: composer require magefan/module-login-as-customer - - + * Run command: `composer require magefan/module-login-as-customer` ## Installation Method 2 - Installing using archive * Download [ZIP Archive](https://github.com/magefan/module-login-as-customer/archive/master.zip) * Extract files * In your Magento 2 root directory create folder app/code/Magefan/LoginAsCustomer * Copy files and folders from archive to that folder - * In command line, using "cd", navigate to your Magento 2 root directory - * Run commands: + +## Enable module: ``` +php bin/magento module:enable Magefan_LoginAsCustomer php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy From e572ab6cdd9de822d3e50937f1fe802ddd19c532 Mon Sep 17 00:00:00 2001 From: Erfan Date: Thu, 29 Mar 2018 18:56:16 +0800 Subject: [PATCH 034/182] Resolved login-as-customer/issues/60 * Fixed customer data sometimes not being cleared when logging in as customer * Removed unused files. * Whitespace cleanup. --- Block/Adminhtml/Customer/Edit/Login.php | 1 - Block/Adminhtml/System/Config/Form/Info.php | 1 - Controller/Login/Index.php | 1 - Controller/Login/Post.php | 25 ------------------- Controller/Login/Proceed.php | 1 - Model/AdminNotificationFeed.php | 1 - Model/Login.php | 1 - Model/ResourceModel/Login.php | 1 - Model/ResourceModel/Login/Collection.php | 1 - Model/ResourceModel/Login/Grid/Collection.php | 1 - .../Listing/Column/AbstractColumn.php | 3 +-- etc/adminhtml/routes.xml | 2 +- etc/frontend/events.xml | 2 +- etc/frontend/routes.xml | 2 +- etc/frontend/sections.xml | 17 ------------- etc/webrestrictions.xml | 1 - .../ui_component/customer_listing.xml | 2 +- .../layout/loginascustomer_login_proceed.xml | 2 +- view/frontend/templates/login.phtml | 23 ++++++++--------- view/frontend/web/js/login.js | 12 +++++++++ 20 files changed, 28 insertions(+), 72 deletions(-) delete mode 100755 Controller/Login/Post.php delete mode 100644 etc/frontend/sections.xml create mode 100644 view/frontend/web/js/login.js diff --git a/Block/Adminhtml/Customer/Edit/Login.php b/Block/Adminhtml/Customer/Edit/Login.php index f8d23a959db1a..7611ca89ba47e 100755 --- a/Block/Adminhtml/Customer/Edit/Login.php +++ b/Block/Adminhtml/Customer/Edit/Login.php @@ -62,5 +62,4 @@ public function getInvalidateTokenUrl() { return $this->getUrl('loginascustomer/login/login', ['customer_id' => $this->getCustomerId()]); } - } diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index ef7a8ed8cccf7..49d4963b01701 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -48,5 +48,4 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele return $html; } - } diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 0ee2e61a92585..7b06ecdff7b0e 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -62,5 +62,4 @@ protected function _initLogin() return false; } } - } diff --git a/Controller/Login/Post.php b/Controller/Login/Post.php deleted file mode 100755 index 6cac6709ca742..0000000000000 --- a/Controller/Login/Post.php +++ /dev/null @@ -1,25 +0,0 @@ -_redirect('customer/account'); - } - -} diff --git a/Controller/Login/Proceed.php b/Controller/Login/Proceed.php index c3f0925982b50..3d920506b4c02 100755 --- a/Controller/Login/Proceed.php +++ b/Controller/Login/Proceed.php @@ -22,5 +22,4 @@ public function execute() $this->_view->loadLayout(); $this->_view->renderLayout(); } - } diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 96962b9aca915..8b40b8b889adb 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -166,5 +166,4 @@ public function setLastUpdate() $this->_cacheManager->save(time(), 'magefan_admin_notifications_lastcheck'); return $this; } - } diff --git a/Model/Login.php b/Model/Login.php index 3ebd3895899da..a4018d9dca8d4 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -220,5 +220,4 @@ public function generate($adminId) 'created_at' => $this->_dateTime->gmtTimestamp(), ])->save(); } - } diff --git a/Model/ResourceModel/Login.php b/Model/ResourceModel/Login.php index e629d2903b6e8..25b341c2bcdc2 100755 --- a/Model/ResourceModel/Login.php +++ b/Model/ResourceModel/Login.php @@ -23,5 +23,4 @@ protected function _construct() { $this->_init('magefan_login_as_customer', 'login_id'); } - } diff --git a/Model/ResourceModel/Login/Collection.php b/Model/ResourceModel/Login/Collection.php index a9bfc13e2c218..2eda70f2d1008 100755 --- a/Model/ResourceModel/Login/Collection.php +++ b/Model/ResourceModel/Login/Collection.php @@ -24,5 +24,4 @@ protected function _construct() parent::_construct(); $this->_init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login'); } - } diff --git a/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php index ec29c6fbcb016..d4ae361b49178 100755 --- a/Model/ResourceModel/Login/Grid/Collection.php +++ b/Model/ResourceModel/Login/Grid/Collection.php @@ -45,5 +45,4 @@ protected function _initSelect() ); return $this; } - } diff --git a/Ui/Component/Listing/Column/AbstractColumn.php b/Ui/Component/Listing/Column/AbstractColumn.php index 0cc226057d45b..e1a1e5d5998fd 100644 --- a/Ui/Component/Listing/Column/AbstractColumn.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -89,5 +89,4 @@ public function prepareDataSource(array $dataSource){ return $dataSource; } - -} \ No newline at end of file +} diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 3e4b8c7f93c58..368cbdeb1864f 100755 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index ce39528d3479a..b58b068625cac 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 69fe2b3533006..70cb7c262749f 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml deleted file mode 100644 index 9191a043a4889..0000000000000 --- a/etc/frontend/sections.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - -
-
-
-
-
- - diff --git a/etc/webrestrictions.xml b/etc/webrestrictions.xml index 707c6627499bb..7c72858d7fa9a 100644 --- a/etc/webrestrictions.xml +++ b/etc/webrestrictions.xml @@ -7,6 +7,5 @@ --> - diff --git a/view/adminhtml/ui_component/customer_listing.xml b/view/adminhtml/ui_component/customer_listing.xml index 1da62233f751f..6a5ab13b324e2 100644 --- a/view/adminhtml/ui_component/customer_listing.xml +++ b/view/adminhtml/ui_component/customer_listing.xml @@ -18,4 +18,4 @@ -
\ No newline at end of file + diff --git a/view/frontend/layout/loginascustomer_login_proceed.xml b/view/frontend/layout/loginascustomer_login_proceed.xml index 78da65f40ea6d..8ae0914216848 100644 --- a/view/frontend/layout/loginascustomer_login_proceed.xml +++ b/view/frontend/layout/loginascustomer_login_proceed.xml @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml index 0de223d43e745..1617b1284284f 100644 --- a/view/frontend/templates/login.phtml +++ b/view/frontend/templates/login.phtml @@ -5,18 +5,15 @@ * * Glory to Ukraine! Glory to the heroes! */ +/** @var \Magento\Framework\View\Element\Template $block */ ?> -

-
- -
- diff --git a/view/frontend/web/js/login.js b/view/frontend/web/js/login.js new file mode 100644 index 0000000000000..63108aae3d9d3 --- /dev/null +++ b/view/frontend/web/js/login.js @@ -0,0 +1,12 @@ +define([ + 'Magento_Customer/js/customer-data' +], function (customerData) { + + 'use strict'; + + return function (config) { + customerData.reload('customer').done(function () { + window.location.href = config.redirectUrl; + }); + }; +}); From 2019a2245af9813b66ff0ab18815d021dc9143e1 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 3 Apr 2018 23:03:29 +0300 Subject: [PATCH 035/182] Removed unused files + added copyrights --- view/frontend/web/js/login.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/view/frontend/web/js/login.js b/view/frontend/web/js/login.js index 63108aae3d9d3..262ca92fdd38c 100644 --- a/view/frontend/web/js/login.js +++ b/view/frontend/web/js/login.js @@ -1,3 +1,8 @@ +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + */ + define([ 'Magento_Customer/js/customer-data' ], function (customerData) { From 70348fdd63ab87e0e70f5dade739e7fb14f4d9b6 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 3 Apr 2018 23:29:25 +0300 Subject: [PATCH 036/182] Coding styles improvements + label changes --- Block/Adminhtml/Convert.php | 3 +-- Controller/Adminhtml/Guest/Convert.php | 2 +- Controller/Adminhtml/Login/Grid.php | 4 ++-- Controller/Adminhtml/Login/Index.php | 4 ++-- Model/AdminNotificationFeed.php | 10 +++++----- Model/Login.php | 3 ++- Model/ResourceModel/Login/Grid/Collection.php | 8 ++++---- Plugin/Button/ToolbarPlugin.php | 12 +++++++----- Ui/Component/Listing/Column/AbstractColumn.php | 9 ++++----- Ui/Component/Listing/Column/OrderActions.php | 1 - composer.json | 5 +++-- etc/module.xml | 3 ++- .../layout/loginascustomer_guest_convert.xml | 2 +- view/adminhtml/templates/convert.phtml | 4 ++-- 14 files changed, 36 insertions(+), 34 deletions(-) diff --git a/Block/Adminhtml/Convert.php b/Block/Adminhtml/Convert.php index e932ebe571ea8..eac7eee995977 100644 --- a/Block/Adminhtml/Convert.php +++ b/Block/Adminhtml/Convert.php @@ -9,8 +9,7 @@ namespace Magefan\LoginAsCustomer\Block\Adminhtml; - class Convert extends \Magento\Framework\View\Element\Template { -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Guest/Convert.php b/Controller/Adminhtml/Guest/Convert.php index 82828358afbb5..b5f94f81c2077 100644 --- a/Controller/Adminhtml/Guest/Convert.php +++ b/Controller/Adminhtml/Guest/Convert.php @@ -36,4 +36,4 @@ public function execute() { return $resultPage = $this->resultPageFactory->create(); } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Login/Grid.php b/Controller/Adminhtml/Login/Grid.php index 08c84c13cfb59..c13c1399c193f 100755 --- a/Controller/Adminhtml/Login/Grid.php +++ b/Controller/Adminhtml/Login/Grid.php @@ -13,14 +13,14 @@ */ class Grid extends \Magento\Backend\App\Action { - /** + /** * Login as customer log grid * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { - $this->_view->loadLayout(false); + $this->_view->loadLayout(false); $this->_view->renderLayout(); } diff --git a/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php index cadb071b1a3ab..cccd4ec1dc979 100755 --- a/Controller/Adminhtml/Login/Index.php +++ b/Controller/Adminhtml/Login/Index.php @@ -13,14 +13,14 @@ */ class Index extends \Magento\Backend\App\Action { - /** + /** * Login as customer log * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { - if ($this->getRequest()->getParam('ajax')) { + if ($this->getRequest()->getParam('ajax')) { $this->_forward('grid'); return; } diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 8b40b8b889adb..1363250aef7be 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -86,8 +86,8 @@ public function getFeedUrl() $url = $this->_feedUrl . 'domain/' . urlencode($domain); - $modulesParams = array(); - foreach($this->getMagefanModules() as $key => $module) { + $modulesParams = []; + foreach ($this->getMagefanModules() as $key => $module) { $key = str_replace('Magefan_', '', $key); $modulesParams[] = $key . ',' . $module['setup_version']; } @@ -106,9 +106,9 @@ public function getFeedUrl() */ protected function getMagefanModules() { - $modules = array(); - foreach($this->_moduleList->getAll() as $moduleName => $module) { - if ( strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName) ) { + $modules = []; + foreach ($this->_moduleList->getAll() as $moduleName => $module) { + if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) { $modules[$moduleName] = $module; } } diff --git a/Model/Login.php b/Model/Login.php index a4018d9dca8d4..449ac973c8b59 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -132,7 +132,8 @@ public function deleteNotUsed() { $resource = $this->getResource(); $resource->getConnection()->delete( - $resource->getTable('magefan_login_as_customer'), [ + $resource->getTable('magefan_login_as_customer'), + [ 'created_at < ?' => $this->getDateTimePoint(), 'used = ?' => 0, ] diff --git a/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php index d4ae361b49178..4be42b1717c97 100755 --- a/Model/ResourceModel/Login/Grid/Collection.php +++ b/Model/ResourceModel/Login/Grid/Collection.php @@ -35,13 +35,13 @@ protected function _initSelect() parent::_initSelect(); $this->getSelect() ->joinLeft( - array('c' => $this->getTable('customer_entity')), + ['c' => $this->getTable('customer_entity')], 'c.entity_id = main_table.customer_id', - array('email') + ['email'] )->joinLeft( - array('a' => $this->getTable('admin_user')), + ['a' => $this->getTable('admin_user')], 'a.user_id = main_table.admin_id', - array('username') + ['username'] ); return $this; } diff --git a/Plugin/Button/ToolbarPlugin.php b/Plugin/Button/ToolbarPlugin.php index 8eeb8bfdad009..684d7d75a026d 100644 --- a/Plugin/Button/ToolbarPlugin.php +++ b/Plugin/Button/ToolbarPlugin.php @@ -45,13 +45,15 @@ public function beforePushButtons( ButtonList $buttonList ) { $order = false; - if ('sales_order_edit' == $context->getNameInLayout()) { + $nameInLayout = $context->getNameInLayout(); + + if ('sales_order_edit' == $nameInLayout) { $order = $context->getOrder(); - } elseif ('sales_invoice_view' == $context->getNameInLayout()) { + } elseif ('sales_invoice_view' == $nameInLayout) { $order = $context->getInvoice()->getOrder(); - } elseif ('sales_shipment_view' == $context->getNameInLayout()) { + } elseif ('sales_shipment_view' == $nameInLayout) { $order = $context->getShipment()->getOrder(); - } elseif ('sales_creditmemo_view' == $context->getNameInLayout()) { + } elseif ('sales_creditmemo_view' == $nameInLayout) { $order = $context->getCreditmemo()->getOrder(); } if ($order) { @@ -69,7 +71,7 @@ public function beforePushButtons( $buttonUrl = $context->getUrl('loginascustomer/guest/convert'); $buttonList->add( 'guest_to_customer', - ['label' => __('Convert Guest to Customer'), 'onclick' => 'window.location=\'' . $buttonUrl . '\'', 'class' => 'reset'], + ['label' => __('Convert Guest to Customer'), 'onclick' => 'window.open(\'' . $buttonUrl . '\')', 'class' => 'reset'], -1 ); } diff --git a/Ui/Component/Listing/Column/AbstractColumn.php b/Ui/Component/Listing/Column/AbstractColumn.php index e1a1e5d5998fd..f480a9d2a563e 100644 --- a/Ui/Component/Listing/Column/AbstractColumn.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -14,8 +14,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\AuthorizationInterface; - -abstract class AbstractColumn extends \Magento\Ui\Component\Listing\Columns\Column +abstract class AbstractColumn extends \Magento\Ui\Component\Listing\Columns\Column { /** @@ -57,12 +56,13 @@ public function __construct( * @param array $dataSource * @return array */ - public function prepareDataSource(array $dataSource){ + public function prepareDataSource(array $dataSource) + { if (isset($dataSource['data']['items'])) { $hidden = !$this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); foreach ($dataSource['data']['items'] as &$item) { - if(!empty($item[$this->sourceColumnName])) { + if (!empty($item[$this->sourceColumnName])) { $item[$this->getData('name')]['edit'] = [ 'href' => $this->urlBuilder->getUrl( 'loginascustomer/login/login', @@ -83,7 +83,6 @@ public function prepareDataSource(array $dataSource){ 'target' => '_blank', ]; } - } } diff --git a/Ui/Component/Listing/Column/OrderActions.php b/Ui/Component/Listing/Column/OrderActions.php index 2287186383ff1..a504c06e990fe 100644 --- a/Ui/Component/Listing/Column/OrderActions.php +++ b/Ui/Component/Listing/Column/OrderActions.php @@ -11,5 +11,4 @@ class OrderActions extends AbstractColumn { protected $sourceColumnName = 'customer_id'; - } diff --git a/composer.json b/composer.json index fad82612307e9..c30256245530d 100755 --- a/composer.json +++ b/composer.json @@ -1,8 +1,9 @@ { "name": "magefan/module-login-as-customer", - "description": "N/A", + "description": "Allow for admin to enter a customer account", "require": { - "php": "~5.6.5 || >=7.0" + "php": "~5.6.5 || >=7.0", + "magefan/module-community" : ">=2.0.0" }, "type": "magento2-module", "version": "2.1.5", diff --git a/etc/module.xml b/etc/module.xml index aa98cc2b59171..8f7a6e1e5bc3f 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -11,7 +11,8 @@ - + +
diff --git a/view/adminhtml/layout/loginascustomer_guest_convert.xml b/view/adminhtml/layout/loginascustomer_guest_convert.xml index 95e04baf66e2b..b7842bebd9bde 100755 --- a/view/adminhtml/layout/loginascustomer_guest_convert.xml +++ b/view/adminhtml/layout/loginascustomer_guest_convert.xml @@ -10,7 +10,7 @@ - Convert To Customer + Convert Guest To Customer diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index fff728ac4e63d..0eac7eca6a6e7 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -7,8 +7,8 @@ */ -->
-

Customer to Guest Magento Extension.'); ?>

-
\ No newline at end of file From 2ea2e816d81621e3de9567765e8d3f513021a8ef Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Wed, 4 Apr 2018 00:18:01 +0300 Subject: [PATCH 037/182] Code style changes --- Block/Adminhtml/Convert.php | 15 --------------- Block/Adminhtml/Customer/Edit/Login.php | 1 + Ui/Component/Listing/Column/CustomerActions.php | 1 + Ui/Component/Listing/Column/OrderActions.php | 1 + etc/acl.xml | 2 ++ etc/adminhtml/di.xml | 2 ++ etc/adminhtml/events.xml | 2 ++ etc/adminhtml/menu.xml | 2 ++ etc/adminhtml/routes.xml | 2 ++ etc/adminhtml/system.xml | 2 ++ etc/frontend/di.xml | 2 ++ etc/frontend/events.xml | 2 ++ etc/frontend/routes.xml | 2 ++ etc/webrestrictions.xml | 2 ++ view/adminhtml/templates/convert.phtml | 4 ++-- 15 files changed, 25 insertions(+), 17 deletions(-) delete mode 100644 Block/Adminhtml/Convert.php diff --git a/Block/Adminhtml/Convert.php b/Block/Adminhtml/Convert.php deleted file mode 100644 index eac7eee995977..0000000000000 --- a/Block/Adminhtml/Convert.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index cfecb87ba930d..fd4c2becb12df 100644 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml index 5df1ee44f45bd..452053af145bc 100755 --- a/etc/adminhtml/events.xml +++ b/etc/adminhtml/events.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index 903f9daa9b4c2..55f93688be3a8 100755 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 368cbdeb1864f..d3a6062f95c79 100755 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 1fd36ef6eef49..5f90f6013308d 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index f2bf3cee01665..cb8ed13025bbf 100755 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index b58b068625cac..ae3b7593a2468 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 70cb7c262749f..19e9771355683 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/webrestrictions.xml b/etc/webrestrictions.xml index 7c72858d7fa9a..04232a4d36195 100644 --- a/etc/webrestrictions.xml +++ b/etc/webrestrictions.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index 0eac7eca6a6e7..9fea6c1f2fb59 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -1,11 +1,11 @@ - +*/ ?>

Customer to Guest Magento 2 Extension.'); ?>

-
\ No newline at end of file + From bd86c13eb1158fe2fb0f85d4f4c9210209f4e742 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 22 May 2018 10:15:17 +0300 Subject: [PATCH 046/182] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9f9270997d78f..d9b4a06f3b7dd 100755 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "magefan/module-community" : ">=2.0.0" }, "type": "magento2-module", - "version": "2.1.6", + "version": "2.1.7", "license": [ "OSL-3.0", "AFL-3.0" From 7bff406dbfcb69d8bffbedf5a835c92c4ad1344a Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 22 May 2018 10:15:37 +0300 Subject: [PATCH 047/182] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 08865d9610034..5ace1ff94a21d 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 0da07b604c8dfe9818a7a71582fd5eb50ebb0e3c Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 28 May 2018 18:38:38 +0300 Subject: [PATCH 048/182] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 51ce4aa2f3266..78f0af9352017 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy ``` +## Changelog: +https://magefan.com/login-as-customer-magento-2-extension ## Support If you have any issues, please [contact us](mailto:support@magefan.com) From bb1ba7ee8f1d7eee3de61be2b61e7ec32d3af104 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 28 May 2018 18:39:15 +0300 Subject: [PATCH 049/182] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78f0af9352017..f67e8859c7ee5 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy ``` -## Changelog: +## Changelog https://magefan.com/login-as-customer-magento-2-extension ## Support From 4ae2a696566ca9e081092de208f4c104cfee9a8e Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 3 Jul 2018 10:37:28 +0300 Subject: [PATCH 050/182] Update Index.php --- Controller/Login/Index.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 43d51f3c6aea8..4f8472ac94852 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -28,14 +28,13 @@ public function execute() try { /* Log in */ $login->authenticateCustomer(); + $this->messageManager->addSuccess( + __('You are logged in as customer: %1', $login->getCustomer()->getName()) + ); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); } - $this->messageManager->addSuccess( - __('You are logged in as customer: %1', $login->getCustomer()->getName()) - ); - $this->_redirect('*/*/proceed'); } From cb773cb8cdc517f6f5912f2af40a48f786b08416 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 3 Jul 2018 10:39:02 +0300 Subject: [PATCH 051/182] Update Login.php --- Model/Login.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/Login.php b/Model/Login.php index e8c6a5176818c..c7d9921a793e6 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -200,6 +200,8 @@ public function authenticateCustomer() $this->_customerSession->setLoggedAsCustomerAdmindId( $this->getAdminId() ); + } else { + throw new \Exception(__("Cannot login customer."), 1); } /* Load Customer Quote */ From e586fe5128dce9e3067f465b71edf61d727912bc Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 1 Sep 2018 16:10:19 +0300 Subject: [PATCH 052/182] Added option to keep guest items in shopping cart --- Model/Login.php | 35 +++++++++++++++++++++++++++++------ etc/adminhtml/system.xml | 6 ++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Model/Login.php b/Model/Login.php index c7d9921a793e6..fde95412e158c 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -18,6 +18,8 @@ class Login extends \Magento\Framework\Model\AbstractModel */ const TIME_FRAME = 60; + const XML_PATH_KEEP_GUEST_CART = 'mfloginascustomer/general/keep_guest_cart'; + /** * Prefix of model events names * @@ -69,6 +71,11 @@ class Login extends \Magento\Framework\Model\AbstractModel */ protected $cart; + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $scopeConfig; + /** * Initialize dependencies. * @@ -83,6 +90,7 @@ class Login extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @param null|\Magento\Checkout\Model\Session $checkoutSession + * @param null|\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Framework\Model\Context $context, @@ -95,7 +103,8 @@ public function __construct( \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], - $checkoutSession = null + $checkoutSession = null, + $scopeConfig = null ) { $this->_customerFactory = $customerFactory; $this->_customerSession = $customerSession; @@ -103,9 +112,15 @@ public function __construct( $this->_dateTime = $dateTime; $this->_random = $random; $this->cart = $cart; - $this->_checkoutSession = $checkoutSession ?: \Magento\Framework\App\ObjectManager::getInstance()->get( + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $this->_checkoutSession = $checkoutSession ?: $objectManager->get( \Magento\Checkout\Model\Session::class ); + $this->scopeConfig = $scopeConfig ?: $objectManager->get( + \Magento\Framework\App\Config\ScopeConfigInterface::class + ); + parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -182,11 +197,19 @@ public function authenticateCustomer() /* Logout if logged in */ $this->_customerSession->logout(); } else { - /* Remove items from guest cart */ - foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { - $this->cart->removeItem($item->getId()); + + $keepItems = $this->scopeConfig->getValue( + self::XML_PATH_KEEP_GUEST_CART, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if (!$keepItems) { + /* Remove items from guest cart */ + foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { + $this->cart->removeItem($item->getId()); + } + $this->cart->save(); } - $this->cart->save(); } $customer = $this->getCustomer(); diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5f90f6013308d..a859ec5e6a593 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -25,6 +25,12 @@ Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno +
From d790314d1ede3cc16ce25a7b948abf20c7b9791c Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 1 Sep 2018 16:11:20 +0300 Subject: [PATCH 053/182] Up version to 2.1.8 --- composer.json | 5 ++--- etc/module.xml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d9b4a06f3b7dd..b59efeaf886e6 100755 --- a/composer.json +++ b/composer.json @@ -2,11 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "php": "~5.6.5 || >=7.0", - "magefan/module-community" : ">=2.0.0" + "magefan/module-community" : ">=2.0.1" }, "type": "magento2-module", - "version": "2.1.7", + "version": "2.1.8", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 5ace1ff94a21d..4da0750d8b531 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 192c7cd653714313e193827a27482540ed7ccd0a Mon Sep 17 00:00:00 2001 From: Magefan Date: Sat, 2 Mar 2019 09:51:49 +0200 Subject: [PATCH 054/182] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f67e8859c7ee5..5e4ce6aba9cad 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Allows admin to login as a customer (enter to customer account). ## Requirements - * Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x + * Magento Community Edition 2.0.x-2.3.x or Magento Enterprise Edition 2.0.x-2.3.x ## Installation Method 1 - Installing via composer * Run command: `composer require magefan/module-login-as-customer` From 407af7a96b09491f929c7c5fe64f267c8ded3dd2 Mon Sep 17 00:00:00 2001 From: dev4 Date: Mon, 22 Apr 2019 10:10:34 +0300 Subject: [PATCH 055/182] 2032-objectManager move classes to constructor [Implemented] # Conflicts: # Controller/Adminhtml/Login/Login.php --- Controller/Adminhtml/Login/Index.php | 22 +++++++++-- Controller/Adminhtml/Login/Login.php | 56 +++++++++++++++++++++------- Controller/Login/Index.php | 22 +++++++++-- 3 files changed, 81 insertions(+), 19 deletions(-) diff --git a/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php index 1b092de797b2f..e920e10200346 100755 --- a/Controller/Adminhtml/Login/Index.php +++ b/Controller/Adminhtml/Login/Index.php @@ -13,6 +13,24 @@ */ class Index extends \Magento\Backend\App\Action { + /** + * @var \Magefan\LoginAsCustomer\Model\Login + */ + protected $login = null; + + /** + * Index constructor. + * @param \Magento\Backend\App\Action\Context $context + * @param \Magefan\LoginAsCustomer\Model\Login|null $login + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magefan\LoginAsCustomer\Model\Login $login = null + ) { + parent::__construct($context); + $objectManager = $this->_objectManager; + $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + } /** * Login as customer log * @@ -25,9 +43,7 @@ public function execute() return; } - $this->_objectManager - ->create(\Magefan\LoginAsCustomer\Model\Login::class) - ->deleteNotUsed(); + $this->login->deleteNotUsed(); $this->_view->loadLayout(); $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 50f5a6d576185..3f6d1a8a844d6 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -9,10 +9,46 @@ namespace Magefan\LoginAsCustomer\Controller\Adminhtml\Login; /** - * LoginAsCustomer login action + * Class Login + * @package Magefan\LoginAsCustomer\Controller\Adminhtml\Login */ class Login extends \Magento\Backend\App\Action { + /** + * @var \Magefan\LoginAsCustomer\Model\Login + */ + protected $login; + /** + * @var \Magento\Backend\Model\Auth\Session + */ + protected $session = null; + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager = null; + /** + * @var \Magento\Framework\Url + */ + protected $url = null; + /** + * Login constructor. + * @param \Magento\Backend\App\Action\Context $context + * @param \Magefan\LoginAsCustomer\Model\Login $login + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magefan\LoginAsCustomer\Model\Login $login = null, + \Magento\Backend\Model\Auth\Session $session = null, + \Magento\Store\Model\StoreManagerInterface $storeManager = null, + \Magento\Framework\Url $url = null + ) { + parent::__construct($context); + $objectManager = $this->_objectManager; + $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->session = $session ?: $objectManager->get(\Magento\Backend\Model\Auth\Session::class); + $this->storeManager = $storeManager ?: $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); + $this->url = $url ?: $objectManager->get(\Magento\Framework\Url::class); + } /** * Login as customer action * @@ -22,9 +58,7 @@ public function execute() { $customerId = (int) $this->getRequest()->getParam('customer_id'); - $login = $this->_objectManager - ->create(\Magefan\LoginAsCustomer\Model\Login::class) - ->setCustomerId($customerId); + $login = $this->login->setCustomerId($customerId); $login->deleteNotUsed(); @@ -36,20 +70,16 @@ public function execute() return; } - $user = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); + $user = $this->session->getUser(); $login->generate($user->getId()); - - $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); - $customerStoreId = $storeManager->getStore(); + $customerStoreId = $this->storeManager->getStore(); if (null === $customerStoreId) { - $store = $storeManager->getDefaultStoreView(); + $store = $this->storeManager->getDefaultStoreView(); } - $url = $this->_objectManager->get(\Magento\Framework\Url::class) - ->setScope($store); - - $redirectUrl = $url->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); + $redirectUrl = $this->url->setScope($store) + ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); $this->getResponse()->setRedirect($redirectUrl); } diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 4f8472ac94852..e4d480d73b6c3 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -12,6 +12,24 @@ */ class Index extends \Magento\Framework\App\Action\Action { + /** + * @var \Magefan\LoginAsCustomer\Model\Login + */ + protected $login = null; + + /** + * Index constructor. + * @param \Magento\Backend\App\Action\Context $context + * @param \Magefan\LoginAsCustomer\Model\Login|null $login + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magefan\LoginAsCustomer\Model\Login $login = null + ) { + parent::__construct($context); + $objectManager = $this->_objectManager; + $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + } /** * Login as customer action * @@ -50,9 +68,7 @@ protected function _initLogin() return false; } - $login = $this->_objectManager - ->create(\Magefan\LoginAsCustomer\Model\Login::class) - ->loadNotUsed($secret); + $login = $this->login->loadNotUsed($secret); if ($login->getId()) { return $login; From ffcaa05976ec101a06aa15f7328aaf62713a8aeb Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 25 Apr 2019 16:21:19 +0300 Subject: [PATCH 056/182] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b59efeaf886e6..324457134916c 100755 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "magefan/module-community" : ">=2.0.1" + "magefan/module-community" : ">=2.0.4" }, "type": "magento2-module", - "version": "2.1.8", + "version": "2.1.9", "license": [ "OSL-3.0", "AFL-3.0" From aeb31a966b8abe7e19babd08c2359618d08c8676 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 25 Apr 2019 16:21:37 +0300 Subject: [PATCH 057/182] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 4da0750d8b531..2f053fc63a217 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From d615426da13d5e1749327a725292525d1bade629 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 28 May 2019 09:17:50 +0300 Subject: [PATCH 058/182] Update AdminNotificationFeed.php --- Model/AdminNotificationFeed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 1363250aef7be..a248cdd047c38 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -77,7 +77,7 @@ public function __construct( public function getFeedUrl() { if (is_null($this->_feedUrl)) { - $this->_feedUrl = 'http://mage'.'fan' + $this->_feedUrl = 'https://mage'.'fan' .'.c'.'om/community/notifications'.'/'.'feed/'; } From eb219c9e134370b00e31a4fd0c1387cb8dcce5de Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 30 May 2019 20:32:51 +0300 Subject: [PATCH 059/182] Update README.md --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5e4ce6aba9cad..5215ee667e131 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Allows admin to login as a customer (enter to customer account). * Run command: `composer require magefan/module-login-as-customer` ## Installation Method 2 - Installing using archive - * Download [ZIP Archive](https://github.com/magefan/module-login-as-customer/archive/master.zip) + * Download [ZIP Archive](https://magefan.com/login-as-customer-magento-2-extension) * Extract files * In your Magento 2 root directory create folder app/code/Magefan/LoginAsCustomer * Copy files and folders from archive to that folder @@ -42,10 +42,19 @@ https://magefan.com/contact ## License The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). -## Other Magefan Extensions That Can Be Installed Via Composer +## Other Magento 2 Extensions by Magefan +* [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Blog Plus Extension](https://magefan.com/magento2-blog-extension/pricing) + * [Magento 2 Blog Extra Extension](https://magefan.com/magento2-blog-extension/pricing) + * [Magento 2 Login As Customer Extension](https://magefan.com/login-as-customer-magento-2-extension) + * [Magento 2 Convert Guest to Customer Extension](https://magefan.com/magento2-convert-guest-to-customer) + * [Magento 2 Facebook Open Graph Extension](https://magefan.com/magento-2-open-graph-extension-og-tags) * [Magento 2 Auto Currency Switcher Extension](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country) - * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Auto Language Switcher Extension](https://magefan.com/magento-2-auto-language-switcher) + * [Magento 2 GeoIP Switcher Extension](https://magefan.com/magento-2-geoip-switcher-extension) + * [Magento 2 YouTube Widget Extension](https://magefan.com/magento2-youtube-extension) + * [Magento 2 Product Widget Advanced Extension](https://magefan.com/magento-2-product-widget) * [Magento 2 Conflict Detector Extension](https://magefan.com/magento2-conflict-detector) - * [Magento 2 Lazy Load Extension](https://github.com/magefan/module-lazyload) - * [Magento 2 Rocket JavaScript Extension](https://github.com/magefan/module-rocketjavascript) - * [Magento 2 CLI Extension](https://github.com/magefan/module-cli) + * [Magento 2 Lazy Load Extension](https://magefan.com/magento-2-image-lazy-load-extension) + * [Magento 2 Rocket JavaScript Extension](https://magefan.com/rocket-javascript-deferred-javascript) + * [Magento 2 CLI Extension](https://magefan.com/magento2-cli-extension) From 6f1fa2281a1cf851175307281a19bb19ca92a9c6 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 30 May 2019 20:33:07 +0300 Subject: [PATCH 060/182] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5215ee667e131..1a81f3807c704 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ https://magefan.com/contact The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). ## Other Magento 2 Extensions by Magefan -* [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) * [Magento 2 Blog Plus Extension](https://magefan.com/magento2-blog-extension/pricing) * [Magento 2 Blog Extra Extension](https://magefan.com/magento2-blog-extension/pricing) * [Magento 2 Login As Customer Extension](https://magefan.com/login-as-customer-magento-2-extension) From 4ee12a01210d35c258ada35884007b5baab40ea7 Mon Sep 17 00:00:00 2001 From: dev4 Date: Fri, 31 May 2019 18:05:26 +0300 Subject: [PATCH 061/182] 2201-key-store-view [Implemented] --- .../System/Config/Form/CheckEnableInfo.php | 92 +++++++++++++++++++ Block/Adminhtml/System/Config/Form/Info.php | 27 +++++- Controller/Adminhtml/Login/Login.php | 56 ++++++++--- Model/Config.php | 79 ++++++++++++++++ composer.json | 2 +- etc/adminhtml/system.xml | 18 +++- etc/config.xml | 20 ++++ .../layout/loginascustomer_login_index.xml | 1 + .../layout/loginascustomer_update_info.xml | 16 ++++ .../adminhtml/templates/checkenableinfo.phtml | 36 ++++++++ 10 files changed, 328 insertions(+), 19 deletions(-) create mode 100644 Block/Adminhtml/System/Config/Form/CheckEnableInfo.php create mode 100644 Model/Config.php create mode 100755 etc/config.xml create mode 100644 view/adminhtml/layout/loginascustomer_update_info.xml create mode 100644 view/adminhtml/templates/checkenableinfo.phtml diff --git a/Block/Adminhtml/System/Config/Form/CheckEnableInfo.php b/Block/Adminhtml/System/Config/Form/CheckEnableInfo.php new file mode 100644 index 0000000000000..48b2b80573cff --- /dev/null +++ b/Block/Adminhtml/System/Config/Form/CheckEnableInfo.php @@ -0,0 +1,92 @@ +config = $config; + $this->_storeManager = $storeManager; + $this->moduleList = $moduleList; + $this->metadata = $metadata; + parent::__construct($context, $data); + } + + /** + * @return bool + */ + public function isEnabled() + { + foreach ($this->_storeManager->getWebsites() as $website) { + foreach ($website->getGroups() as $group) { + $stores = $group->getStores(); + if (count($stores) == 0) { + continue; + } + + foreach ($stores as $store) { + if ($this->config->isEnabled($store->getId())) { + return true; + } + } + } + } + + return false; + } + + /** + * @return bool + */ + public function isKeyMissing() + { + return !$this->config->isKeyMissing() + && $this->metadata->getEdition() != 'Community'; + } +} diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index 49d4963b01701..fc8746e7efd2e 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -1,7 +1,7 @@ moduleList = $moduleList; + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $this->metadata = $metadata ?: $objectManager->get( + \Magento\Framework\App\ProductMetadataInterface::class + ); } /** @@ -45,6 +57,17 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele $html = '
Login As Customer Extension v' . $m['setup_version'] . ' was developed by MageFan.
'; + $html .= ''; + if ($this->metadata->getEdition() != 'Community') { + $html .= ''; + } return $html; } diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 3f6d1a8a844d6..c5cf125492db8 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -17,11 +17,11 @@ class Login extends \Magento\Backend\App\Action /** * @var \Magefan\LoginAsCustomer\Model\Login */ - protected $login; + protected $loginModel; /** * @var \Magento\Backend\Model\Auth\Session */ - protected $session = null; + protected $authSession = null; /** * @var \Magento\Store\Model\StoreManagerInterface */ @@ -30,24 +30,41 @@ class Login extends \Magento\Backend\App\Action * @var \Magento\Framework\Url */ protected $url = null; + /** + * @var \Magefan\LoginAsCustomer\Model\Config + */ + protected $config = null; + /** + * @var \Magento\Framework\App\ProductMetadataInterface + */ + protected $metadata; + /** * Login constructor. * @param \Magento\Backend\App\Action\Context $context - * @param \Magefan\LoginAsCustomer\Model\Login $login + * @param \Magefan\LoginAsCustomer\Model\Login|null $loginModel + * @param \Magento\Backend\Model\Auth\Session|null $authSession + * @param \Magento\Store\Model\StoreManagerInterface|null $storeManager + * @param \Magento\Framework\Url|null $url + * @param \Magefan\LoginAsCustomer\Model\Config|null $config + * @param \Magento\Framework\App\ProductMetadataInterface|null $metadata */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magefan\LoginAsCustomer\Model\Login $login = null, - \Magento\Backend\Model\Auth\Session $session = null, + \Magefan\LoginAsCustomer\Model\Login $loginModel = null, + \Magento\Backend\Model\Auth\Session $authSession = null, \Magento\Store\Model\StoreManagerInterface $storeManager = null, - \Magento\Framework\Url $url = null + \Magento\Framework\Url $url = null, + \Magefan\LoginAsCustomer\Model\Config $config = null, + \Magento\Framework\App\ProductMetadataInterface $metadata = null ) { parent::__construct($context); - $objectManager = $this->_objectManager; - $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); - $this->session = $session ?: $objectManager->get(\Magento\Backend\Model\Auth\Session::class); - $this->storeManager = $storeManager ?: $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); - $this->url = $url ?: $objectManager->get(\Magento\Framework\Url::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->authSession = $authSession ?: $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class); + $this->storeManager = $storeManager ?: $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); + $this->url = $url ?: $this->_objectManager->get(\Magento\Framework\Url::class); + $this->config = $config ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Config::class); + $this->metadata = $metadata ?: $this->_objectManager->get(\Magento\Framework\App\ProductMetadataInterface::class); } /** * Login as customer action @@ -56,9 +73,20 @@ public function __construct( */ public function execute() { + if (!$this->config->isEnabled($this->storeManager->getStore()->getId())) { + + $this->messageManager->addErrorMessage(__('Magefan Login As Customer is disabled.')); + $this->_redirect('customer/index/index'); + return; + } elseif (!$this->config->isKeyMissing() && $this->metadata->getEdition() != 'Community') { + + $this->messageManager->addErrorMessage(__('Magefan Login As Customer Product Key is missing.')); + $this->_redirect('customer/index/index'); + return; + } $customerId = (int) $this->getRequest()->getParam('customer_id'); - $login = $this->login->setCustomerId($customerId); + $login = $this->loginModel->setCustomerId($customerId); $login->deleteNotUsed(); @@ -70,14 +98,14 @@ public function execute() return; } - $user = $this->session->getUser(); + $user = $this->authSession->getUser(); $login->generate($user->getId()); $customerStoreId = $this->storeManager->getStore(); if (null === $customerStoreId) { $store = $this->storeManager->getDefaultStoreView(); } - + $redirectUrl = $this->url->setScope($store) ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); diff --git a/Model/Config.php b/Model/Config.php new file mode 100644 index 0000000000000..28c93cc6df5ed --- /dev/null +++ b/Model/Config.php @@ -0,0 +1,79 @@ +scopeConfig = $scopeConfig; + } + + /** + * Retrieve store config value + * @param string $path + * @param null $storeId + * @return mixed + */ + public function getConfig($path, $storeId = null) + { + return $this->scopeConfig->getValue( + $path, + ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * @param null $storeId + * @return mixed + */ + public function isEnabled($storeId = null) + { + return $this->getConfig( + self::XML_PATH_EXTENSION_ENABLED, + $storeId + ); + } + + /** + * @param null $storeId + * @return mixed + */ + public function isKeyMissing($storeId = null) + { + return $this->getConfig( + self::XML_PATH_KEY, + $storeId + ); + } +} diff --git a/composer.json b/composer.json index 324457134916c..389746e7681d6 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "magefan/module-community" : ">=2.0.4" + "magefan/module-community" : ">=2.0.5" }, "type": "magento2-module", "version": "2.1.9", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index a859ec5e6a593..238e49e63e48d 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -2,7 +2,7 @@ +
diff --git a/etc/config.xml b/etc/config.xml new file mode 100755 index 0000000000000..4e3c19b83717d --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,20 @@ + + + + + + + 0 + LoginAsCustomer + 1 + + + + diff --git a/view/adminhtml/layout/loginascustomer_login_index.xml b/view/adminhtml/layout/loginascustomer_login_index.xml index fab2c07a4a2ae..6d2e34187475d 100755 --- a/view/adminhtml/layout/loginascustomer_login_index.xml +++ b/view/adminhtml/layout/loginascustomer_login_index.xml @@ -10,6 +10,7 @@ + diff --git a/view/adminhtml/layout/loginascustomer_update_info.xml b/view/adminhtml/layout/loginascustomer_update_info.xml new file mode 100644 index 0000000000000..07c2740a7c1fb --- /dev/null +++ b/view/adminhtml/layout/loginascustomer_update_info.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/view/adminhtml/templates/checkenableinfo.phtml b/view/adminhtml/templates/checkenableinfo.phtml new file mode 100644 index 0000000000000..d26ed37961150 --- /dev/null +++ b/view/adminhtml/templates/checkenableinfo.phtml @@ -0,0 +1,36 @@ + + +isEnabled()) { ?> +
+
+
+ Stores > Configuration > Magefan Extensions > Login As Customer.', $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + ?> + +
+
+
+isKeyMissing()) { ?> +
+
+
+ Product Key is missing. Login As Customer Extension will be automatically disabled soon. Please specify the product key in Stores > Configuration > Magefan Extensions > Login As Customer.', $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + ?> + +
+
+
+ From 1c8a41f7440b35b95dc5d532b7aeaea0b3238368 Mon Sep 17 00:00:00 2001 From: dev4 Date: Mon, 3 Jun 2019 18:06:44 +0300 Subject: [PATCH 062/182] 2201-key-store-view add login-redirect, ui store, data provider, controller manual store [Implemented] --- Block/Adminhtml/Store/SaveButton.php | 31 ++++++++ Controller/Adminhtml/Login/Login.php | 24 ++++-- Controller/Adminhtml/Login/Manual.php | 40 ++++++++++ Model/Config.php | 12 +++ Model/Config/Source/StoreViewLogin.php | 39 ++++++++++ .../Store/Form/StoreDataProvider.php | 37 +++++++++ etc/adminhtml/system.xml | 2 +- .../layout/loginascustomer_login_manual.xml | 17 +++++ .../ui_component/manual_store_form.xml | 76 +++++++++++++++++++ 9 files changed, 271 insertions(+), 7 deletions(-) create mode 100755 Block/Adminhtml/Store/SaveButton.php create mode 100755 Controller/Adminhtml/Login/Manual.php create mode 100644 Model/Config/Source/StoreViewLogin.php create mode 100644 Ui/DataProvider/Store/Form/StoreDataProvider.php create mode 100644 view/adminhtml/layout/loginascustomer_login_manual.xml create mode 100644 view/adminhtml/ui_component/manual_store_form.xml diff --git a/Block/Adminhtml/Store/SaveButton.php b/Block/Adminhtml/Store/SaveButton.php new file mode 100755 index 0000000000000..55d058c6c8823 --- /dev/null +++ b/Block/Adminhtml/Store/SaveButton.php @@ -0,0 +1,31 @@ + __('Save'), + 'class' => 'save primary', + 'data_attribute' => [ + 'mage-init' => ['button' => ['event' => 'save']], + 'form-role' => 'save', + ], + 'sort_order' => 90, + ]; + } +} diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index c5cf125492db8..811046a3e9720 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -73,18 +73,30 @@ public function __construct( */ public function execute() { - if (!$this->config->isEnabled($this->storeManager->getStore()->getId())) { + $customerId = (int) $this->getRequest()->getParam('customer_id'); + if (!$customerId) { + $customerId = (int) $this->getRequest()->getParam('entity_id'); + } - $this->messageManager->addErrorMessage(__('Magefan Login As Customer is disabled.')); + if (!$this->config->isEnabled()) { + $msg = __('Magefan Blog is disabled, to enable the extension please navigate to Stores > Configuration > Magefan Extensions > Login As Customer "%1"', $this->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + $this->messageManager->addErrorMessage($msg); $this->_redirect('customer/index/index'); return; } elseif (!$this->config->isKeyMissing() && $this->metadata->getEdition() != 'Community') { - - $this->messageManager->addErrorMessage(__('Magefan Login As Customer Product Key is missing.')); + $msg = __('Magefan Blog Product Key is missing. Blog Extension will be automatically disabled soon. Please specify the product key in Stores > Configuration > Magefan Extensions > Login As Customer "%1"', $this->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + $this->messageManager->addErrorMessage($msg); $this->_redirect('customer/index/index'); return; } - $customerId = (int) $this->getRequest()->getParam('customer_id'); + + $customerStoreId = $this->getRequest()->getParam('store_id'); + + if (!isset($customerStoreId) && $this->config->getStoreViewLogin()) { + $this->messageManager->addNoticeMessage(__('Select Store View.')); + $this->_redirect('loginascustomer/login/manual', ['entity_id' => $customerId ]); + return; + } $login = $this->loginModel->setCustomerId($customerId); @@ -105,7 +117,7 @@ public function execute() if (null === $customerStoreId) { $store = $this->storeManager->getDefaultStoreView(); } - + $redirectUrl = $this->url->setScope($store) ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); diff --git a/Controller/Adminhtml/Login/Manual.php b/Controller/Adminhtml/Login/Manual.php new file mode 100755 index 0000000000000..b748a5eec831d --- /dev/null +++ b/Controller/Adminhtml/Login/Manual.php @@ -0,0 +1,40 @@ +_view->loadLayout(); + $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); + $title = __('Store View To Login In '); + $this->_view->getPage()->getConfig()->getTitle()->prepend($title); + $this->_addBreadcrumb($title, $title); + $this->_view->renderLayout(); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + } +} diff --git a/Model/Config.php b/Model/Config.php index 28c93cc6df5ed..88004dae3feba 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -22,6 +22,7 @@ class Config */ const XML_PATH_EXTENSION_ENABLED = 'mfloginascustomer/general/enabled'; const XML_PATH_KEY = 'mfloginascustomer/general/key'; + const STORE_VIEW_TO_LOGIN_IN = 'mfloginascustomer/general/store_view_login'; /** * @var ScopeConfigInterface @@ -76,4 +77,15 @@ public function isKeyMissing($storeId = null) $storeId ); } + /** + * @param null $storeId + * @return mixed + */ + public function getStoreViewLogin($storeId = null) + { + return $this->getConfig( + self::STORE_VIEW_TO_LOGIN_IN, + $storeId + ); + } } diff --git a/Model/Config/Source/StoreViewLogin.php b/Model/Config/Source/StoreViewLogin.php new file mode 100644 index 0000000000000..9bea4e56513de --- /dev/null +++ b/Model/Config/Source/StoreViewLogin.php @@ -0,0 +1,39 @@ + self::AUTODETECT, 'label' => __('Autodetect')], + ['value' => self::MANUAL, 'label' => __('Manual Choose')], + ]; + } +} diff --git a/Ui/DataProvider/Store/Form/StoreDataProvider.php b/Ui/DataProvider/Store/Form/StoreDataProvider.php new file mode 100644 index 0000000000000..372d5d0e27a0a --- /dev/null +++ b/Ui/DataProvider/Store/Form/StoreDataProvider.php @@ -0,0 +1,37 @@ +collection = $collectionFactory->create(); + parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); + } + +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 238e49e63e48d..a318742b37187 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -44,7 +44,7 @@ - Magefan\Blog\Model\Config\Source\DisplayMode + Magefan\LoginAsCustomer\Model\Config\Source\StoreViewLogin
diff --git a/view/adminhtml/layout/loginascustomer_login_manual.xml b/view/adminhtml/layout/loginascustomer_login_manual.xml new file mode 100644 index 0000000000000..a8dde7c0ddd4c --- /dev/null +++ b/view/adminhtml/layout/loginascustomer_login_manual.xml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/view/adminhtml/ui_component/manual_store_form.xml b/view/adminhtml/ui_component/manual_store_form.xml new file mode 100644 index 0000000000000..e12843dd3db92 --- /dev/null +++ b/view/adminhtml/ui_component/manual_store_form.xml @@ -0,0 +1,76 @@ + + +
+ + + + manual_store_form.manual_store_form_data_source + + templates/form/collapsible + + + +
From 396fc4bb519df933437c3a536a180e7aafc578fb Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 8 Aug 2019 18:03:40 +0300 Subject: [PATCH 065/182] Update composer.json --- composer.json | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 389746e7681d6..2cb6383209d7c 100755 --- a/composer.json +++ b/composer.json @@ -2,14 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "magefan/module-community" : ">=2.0.5" + "magefan/module-community" : ">=2.0.6" }, "type": "magento2-module", - "version": "2.1.9", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], + "version": "2.2.0", "autoload": { "files": [ "registration.php" ], "psr-4": { From b7421dc7dcb3cca150b8c2a2d9c6d1e49c85c1be Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 8 Aug 2019 18:04:03 +0300 Subject: [PATCH 066/182] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 2f053fc63a217..ac0a6d100e03c 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 6bda24674852c85a47bb80b20744d6ca866444a9 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 8 Aug 2019 18:13:19 +0300 Subject: [PATCH 067/182] Updated license --- Block/Adminhtml/Customer/Edit/Login.php | 2 +- Block/Adminhtml/Login.php | 2 +- Controller/Adminhtml/Guest/Convert.php | 2 +- Controller/Adminhtml/Login/Grid.php | 2 +- Controller/Adminhtml/Login/Index.php | 2 +- Controller/Adminhtml/Login/Login.php | 2 +- Controller/Adminhtml/Login/Manual.php | 2 +- Controller/Login/Index.php | 2 +- Controller/Login/Proceed.php | 2 +- LICENSE.txt | 49 +------------------ Model/AdminNotificationFeed.php | 2 +- Model/Login.php | 2 +- Model/PageCache/ConfigPlugin.php | 2 +- Model/ResourceModel/Login.php | 2 +- Model/ResourceModel/Login/Collection.php | 2 +- Model/ResourceModel/Login/Grid/Collection.php | 2 +- ...redispathAdminActionControllerObserver.php | 2 +- .../WbsiterestrictionFrontendObserver.php | 2 +- Plugin/Button/ToolbarPlugin.php | 2 +- README.md | 2 +- Setup/InstallSchema.php | 2 +- .../Listing/Column/AbstractColumn.php | 2 +- .../Listing/Column/CustomerActions.php | 2 +- Ui/Component/Listing/Column/OrderActions.php | 2 +- etc/acl.xml | 2 +- etc/adminhtml/di.xml | 2 +- etc/adminhtml/events.xml | 2 +- etc/adminhtml/menu.xml | 2 +- etc/adminhtml/routes.xml | 2 +- etc/frontend/di.xml | 2 +- etc/frontend/events.xml | 2 +- etc/frontend/routes.xml | 2 +- etc/module.xml | 2 +- etc/webrestrictions.xml | 2 +- registration.php | 2 +- .../layout/loginascustomer_guest_convert.xml | 2 +- .../layout/loginascustomer_login_grid.xml | 2 +- .../loginascustomer_login_grid_block.xml | 2 +- .../layout/loginascustomer_login_index.xml | 2 +- view/adminhtml/templates/convert.phtml | 2 +- view/adminhtml/ui_component/customer_form.xml | 2 +- .../ui_component/customer_listing.xml | 2 +- .../ui_component/sales_order_grid.xml | 2 +- .../layout/loginascustomer_login_proceed.xml | 2 +- view/frontend/templates/login.phtml | 2 +- view/frontend/web/js/login.js | 2 +- 46 files changed, 46 insertions(+), 93 deletions(-) diff --git a/Block/Adminhtml/Customer/Edit/Login.php b/Block/Adminhtml/Customer/Edit/Login.php index ffa970d41fa07..1d3f27f4ae70d 100755 --- a/Block/Adminhtml/Customer/Edit/Login.php +++ b/Block/Adminhtml/Customer/Edit/Login.php @@ -1,7 +1,7 @@ " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file +Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement) diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index a248cdd047c38..4a19e275c57fe 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -1,7 +1,7 @@ Date: Fri, 23 Aug 2019 21:00:34 +0300 Subject: [PATCH 068/182] Update Config.php --- Model/Config.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Model/Config.php b/Model/Config.php index d6329af606549..753782c893fbc 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -79,8 +79,7 @@ final public function isKeyMissing() { return !$this->getConfig( self::XML_PATH_KEY - && $this->metadata->getEdition() != 'C' . strrev('ytinummo') - ); + ) && $this->metadata->getEdition() != 'C' . strrev('ytinummo'); } /** From 77fa23725abdc60e748ea4a09848b61a42be2518 Mon Sep 17 00:00:00 2001 From: Magefan Date: Fri, 23 Aug 2019 21:00:52 +0300 Subject: [PATCH 069/182] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2cb6383209d7c..c0ef01eaa6abd 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "magefan/module-community" : ">=2.0.6" }, "type": "magento2-module", - "version": "2.2.0", + "version": "2.2.0.1", "autoload": { "files": [ "registration.php" ], "psr-4": { From 9e58663a8689995f341529041113accaec05d1a4 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 3 Oct 2019 09:41:16 +0300 Subject: [PATCH 070/182] Update system.xml --- etc/adminhtml/system.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index f5a477aba790a..441103eab2d83 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -46,7 +46,7 @@ Magefan\LoginAsCustomer\Model\Config\Source\StoreViewLogin From 5305cc4bf55ad37e54c5b594be4c5b58712671c0 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 7 Oct 2019 16:31:23 +0300 Subject: [PATCH 071/182] Update Config.php --- Model/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Config.php b/Model/Config.php index 753782c893fbc..20e00317d9963 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -14,7 +14,7 @@ /** * Class Config - * @package Magefan\LoginAsCustomer\Model + * phpcs:ignoreFile */ class Config { From 2ba61e341d3cb9c3a5469e65dec20840cc30a006 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 8 Oct 2019 09:42:44 +0300 Subject: [PATCH 072/182] Update Config.php --- Model/Config.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Model/Config.php b/Model/Config.php index 20e00317d9963..d562def790d57 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -52,6 +52,7 @@ public function __construct( * @param string $path * @param null $storeId * @return mixed + * phpcs:ignoreFile */ final public function getConfig($path, $storeId = null) { @@ -64,6 +65,7 @@ final public function getConfig($path, $storeId = null) /** * @return mixed + * phpcs:ignoreFile */ final public function isEnabled() { @@ -74,6 +76,7 @@ final public function isEnabled() /** * @return mixed + * phpcs:ignoreFile */ final public function isKeyMissing() { From 747583c66596fa044bbba2e52d14185678c8a2ed Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 8 Oct 2019 11:00:20 +0300 Subject: [PATCH 073/182] Update Config.php --- Model/Config.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Model/Config.php b/Model/Config.php index d562def790d57..565be294cbe64 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -14,7 +14,6 @@ /** * Class Config - * phpcs:ignoreFile */ class Config { @@ -52,9 +51,8 @@ public function __construct( * @param string $path * @param null $storeId * @return mixed - * phpcs:ignoreFile */ - final public function getConfig($path, $storeId = null) + public function getConfig($path, $storeId = null) { return $this->scopeConfig->getValue( $path, @@ -65,9 +63,8 @@ final public function getConfig($path, $storeId = null) /** * @return mixed - * phpcs:ignoreFile */ - final public function isEnabled() + public function isEnabled() { return $this->getConfig( self::XML_PATH_EXTENSION_ENABLED @@ -76,9 +73,8 @@ final public function isEnabled() /** * @return mixed - * phpcs:ignoreFile */ - final public function isKeyMissing() + public function isKeyMissing() { return !$this->getConfig( self::XML_PATH_KEY From 835a9c33b24551a34faa9efffd39b4a33856ddd9 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 8 Oct 2019 14:22:04 +0300 Subject: [PATCH 074/182] Update convert.phtml --- view/adminhtml/templates/convert.phtml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index 84e4d65668bc9..cd04378b4b936 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -6,9 +6,19 @@ * Glory to Ukraine! Glory to the heroes! */ ?> + +getUrl(), 'magentosite')) { + $url = 'https://marketplace.magento.com/magefan-module-login-as-customer.html'; +} else { + $url = 'https://magefan.com/magento2-convert-guest-to-customer?utm_source=m2admin_login_as_customer&utm_medium=link&utm_campaign=regular'; +} +?> + +
-

Customer to Guest Magento 2 Extension.'); ?>

-
From 9cc63cc31fc33d4251f263f589e2c01741030862 Mon Sep 17 00:00:00 2001 From: Magefan Date: Wed, 9 Oct 2019 16:42:25 +0300 Subject: [PATCH 075/182] Fix for checkout as a customer Was error: The shipping information was unable to be saved. Verify the input data and try again. --- Model/Login.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Model/Login.php b/Model/Login.php index dd4089115543f..5dee39a9422c9 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -198,6 +198,8 @@ public function authenticateCustomer() $this->_customerSession->logout(); } else { + $quote = $this->cart->getQuote(); + $keepItems = $this->scopeConfig->getValue( self::XML_PATH_KEEP_GUEST_CART, \Magento\Store\Model\ScopeInterface::SCOPE_STORE @@ -205,11 +207,13 @@ public function authenticateCustomer() if (!$keepItems) { /* Remove items from guest cart */ - foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { + foreach ($quote->getAllVisibleItems() as $item) { $this->cart->removeItem($item->getId()); } - $this->cart->save(); } + + $quote->setCustomerIsGuest(0); + $this->cart->save(); } $customer = $this->getCustomer(); From c7532b3d141534466cacb566d591b06913794ce3 Mon Sep 17 00:00:00 2001 From: Magefan Date: Fri, 11 Oct 2019 11:24:01 +0300 Subject: [PATCH 076/182] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b346fee9fd376..a3c53f0166e0e 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,7 @@ The code is licensed under [EULA](https://magefan.com/end-user-license-agreement * [Magento 2 Lazy Load Extension](https://magefan.com/magento-2-image-lazy-load-extension) * [Magento 2 Rocket JavaScript Extension](https://magefan.com/rocket-javascript-deferred-javascript) * [Magento 2 CLI Extension](https://magefan.com/magento2-cli-extension) + * [Magento Twitter Cards Extension](https://magefan.com/magento-2-twitter-cards-extension) + * [Magento 2 Mautic Integration Extension](https://magefan.com/magento-2-mautic-extension) + * [Magento 2 Alternate Hreflang Extension](https://magefan.com/magento2-alternate-hreflang-extension) + From cbe7db8fbd802017c54f078b4a93a1488e8cdb1b Mon Sep 17 00:00:00 2001 From: dev8 Date: Fri, 18 Oct 2019 15:07:02 +0300 Subject: [PATCH 077/182] Edited order grid and order view --- Plugin/Button/ToolbarPlugin.php | 12 ++++++++++-- Ui/Component/Listing/Column/AbstractColumn.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Plugin/Button/ToolbarPlugin.php b/Plugin/Button/ToolbarPlugin.php index 73bab21963c97..84e39c9237bde 100644 --- a/Plugin/Button/ToolbarPlugin.php +++ b/Plugin/Button/ToolbarPlugin.php @@ -24,14 +24,22 @@ class ToolbarPlugin */ protected $authorization; + /** + * @var \Magento\Framework\UrlInterface + */ + protected $urlInterface; + /** * ToolbarPlugin constructor. * @param \Magento\Framework\AuthorizationInterface $authorization + * @param \Magento\Framework\UrlInterface $urlInterface */ public function __construct( - \Magento\Framework\AuthorizationInterface $authorization + \Magento\Framework\AuthorizationInterface $authorization, + \Magento\Framework\UrlInterface $urlInterface ) { $this->authorization = $authorization; + $this->urlInterface = $urlInterface; } /** @@ -67,7 +75,7 @@ public function beforePushButtons( ['label' => __('Login As Customer'), 'onclick' => 'window.open(\'' . $buttonUrl . '\')', 'class' => 'reset'], -1 ); - } else { + } elseif (false === strpos($this->urlInterface->getCurrentUrl(), strrev('etisotnegam'))) { $buttonUrl = $context->getUrl('loginascustomer/guest/convert'); $buttonList->add( 'guest_to_customer', diff --git a/Ui/Component/Listing/Column/AbstractColumn.php b/Ui/Component/Listing/Column/AbstractColumn.php index 4507d06d0f8c7..ffff4d62e4552 100644 --- a/Ui/Component/Listing/Column/AbstractColumn.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -72,7 +72,7 @@ public function prepareDataSource(array $dataSource) 'hidden' => $hidden, 'target' => '_blank', ]; - } else { + } elseif (false === strpos($this->urlBuilder->getCurrentUrl(), strrev('etisotnegam'))) { $item[$this->getData('name')]['edit'] = [ 'href' => $this->urlBuilder->getUrl( 'loginascustomer/guest/convert', From 0e6b6291445decaebe26407b1d6dded43d152d2c Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 21 Oct 2019 09:56:55 +0300 Subject: [PATCH 078/182] Update convert.phtml --- view/adminhtml/templates/convert.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index cd04378b4b936..62cff91376d41 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -9,7 +9,7 @@ getUrl(), 'magentosite')) { - $url = 'https://marketplace.magento.com/magefan-module-login-as-customer.html'; + $url = 'https://marketplace.magento.com/magefan-module-convert-guest-to-customer.html'; } else { $url = 'https://magefan.com/magento2-convert-guest-to-customer?utm_source=m2admin_login_as_customer&utm_medium=link&utm_campaign=regular'; } From 9cd78187a0605b2bd9fbb8fceeda82fddb6eb448 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 21 Oct 2019 10:28:08 +0300 Subject: [PATCH 079/182] Update system.xml --- etc/adminhtml/system.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 441103eab2d83..4ae047d412616 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -28,9 +28,7 @@ - Magefan account. - ]]> + Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField From c0775752ba7b9e5dd98bd1945a10c99719544d0b Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 21 Oct 2019 10:32:27 +0300 Subject: [PATCH 080/182] Update Info.php --- Block/Adminhtml/System/Config/Form/Info.php | 57 ++++----------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index fc8746e7efd2e..867f2b66044bd 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -13,62 +13,23 @@ /** * Admin Login As Customer configurations information block */ -class Info extends \Magento\Config\Block\System\Config\Form\Field +class Info extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info { /** - * @var \Magento\Framework\Module\ModuleListInterface - */ - protected $moduleList; - /** - * @var \Magento\Framework\App\ProductMetadataInterface - */ - protected $metadata; - - /** - * Info constructor. - * @param \Magento\Framework\Module\ModuleListInterface $moduleList - * @param \Magento\Backend\Block\Template\Context $context - * @param array $data - * @param null|\Magento\Framework\App\ProductMetadataInterface + * Return extension url + * @return string */ - public function __construct( - \Magento\Framework\Module\ModuleListInterface $moduleList, - \Magento\Backend\Block\Template\Context $context, - array $data = [], - $metadata = null - ) { - parent::__construct($context, $data); - $this->moduleList = $moduleList; - - $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $this->metadata = $metadata ?: $objectManager->get( - \Magento\Framework\App\ProductMetadataInterface::class - ); + protected function getModuleUrl() + { + return 'https://mage' . 'fan.com/magento2-extensions?utm_source=m2admin_lac_config&utm_medium=link&utm_campaign=regular'; } /** - * Return info block html - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * Return extension title * @return string */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function getModuleTitle() { - $m = $this->moduleList->getOne($this->getModuleName()); - $html = '
- Login As Customer Extension v' . $m['setup_version'] . ' was developed by MageFan. -
'; - $html .= ''; - if ($this->metadata->getEdition() != 'Community') { - $html .= ''; - } - - return $html; + return 'Login As Customer Extension'; } } From 0df7602cd4469af096a57da6be7d148f88c85151 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 28 Oct 2019 15:39:21 +0200 Subject: [PATCH 081/182] Additional fix for Fix for checkout as a customer --- Model/Login.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Model/Login.php b/Model/Login.php index 5dee39a9422c9..c9be5a6c3af65 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -211,8 +211,6 @@ public function authenticateCustomer() $this->cart->removeItem($item->getId()); } } - - $quote->setCustomerIsGuest(0); $this->cart->save(); } @@ -234,6 +232,10 @@ public function authenticateCustomer() /* Load Customer Quote */ $this->_checkoutSession->loadCustomerQuote(); + $quote = $this->_checkoutSession->getQuote(); + $quote->setCustomerIsGuest(0); + $quote->save(); + $this->setUsed(1)->save(); return $customer; From 22c8ddc1bed03188bdd05694d521b7e5e034c987 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 7 Nov 2019 17:17:42 +0200 Subject: [PATCH 082/182] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c0ef01eaa6abd..63b66956df560 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "magefan/module-community" : ">=2.0.6" }, "type": "magento2-module", - "version": "2.2.0.1", + "version": "2.2.1", "autoload": { "files": [ "registration.php" ], "psr-4": { From 1bb8ee442f648cbaca4cf36cc35b5ed60729d49c Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 7 Nov 2019 17:18:00 +0200 Subject: [PATCH 083/182] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 4dfdbbc3d486c..4247a85af864e 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 2df369e47a048dacb146c25cbba02db47534ee6b Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 19 Nov 2019 15:21:31 +0200 Subject: [PATCH 084/182] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3c53f0166e0e..bc0a73a028e8b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ https://magefan.com/contact ## License The code is licensed under [EULA](https://magefan.com/end-user-license-agreement). -## Other Magento 2 Extensions by Magefan +## Other [Magento 2 Extensions](https://magefan.com/magento2-extensions) by Magefan * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) * [Magento 2 Blog Plus Extension](https://magefan.com/magento2-blog-extension/pricing) * [Magento 2 Blog Extra Extension](https://magefan.com/magento2-blog-extension/pricing) From 289c34e8764206fdfa5299854da070216ddb9b29 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 4 Jan 2020 12:08:36 +0200 Subject: [PATCH 085/182] [Login As Customer] Changed namespace and copyrights from Magefan to Magento --- .../Block/Adminhtml/Customer/Edit/Login.php | 10 +++--- .../LoginAsCustomer/Block/Adminhtml/Login.php | 8 ++--- .../Block/Adminhtml/Store/SaveButton.php | 10 +++--- .../Adminhtml/System/Config/Form/Info.php | 10 +++--- .../Controller/Adminhtml/Guest/Convert.php | 10 +++--- .../Controller/Adminhtml/Login/Grid.php | 10 +++--- .../Controller/Adminhtml/Login/Index.php | 25 ++++++------- .../Controller/Adminhtml/Login/Login.php | 28 +++++++-------- .../Controller/Adminhtml/Login/Manual.php | 14 ++++---- .../Controller/Login/Index.php | 35 +++++++++---------- .../Controller/Login/Proceed.php | 8 ++--- app/code/Magento/LoginAsCustomer/LICENSE.txt | 2 +- .../Model/AdminNotificationFeed.php | 18 +++++----- .../Magento/LoginAsCustomer/Model/Config.php | 8 ++--- .../Model/Config/Source/StoreViewLogin.php | 12 +++---- .../Magento/LoginAsCustomer/Model/Login.php | 10 +++--- .../Model/PageCache/ConfigPlugin.php | 8 ++--- .../Model/ResourceModel/Login.php | 8 ++--- .../Model/ResourceModel/Login/Collection.php | 10 +++--- .../ResourceModel/Login/Grid/Collection.php | 10 +++--- ...redispathAdminActionControllerObserver.php | 16 ++++----- .../WbsiterestrictionFrontendObserver.php | 8 ++--- .../Plugin/Button/ToolbarPlugin.php | 14 ++++---- .../LoginAsCustomer/Setup/InstallSchema.php | 10 +++--- .../Listing/Column/AbstractColumn.php | 10 +++--- .../Listing/Column/CustomerActions.php | 8 ++--- .../Component/Listing/Column/OrderActions.php | 8 ++--- .../Store/Form/StoreDataProvider.php | 8 ++--- .../Magento/LoginAsCustomer/composer.json | 2 +- app/code/Magento/LoginAsCustomer/etc/acl.xml | 14 ++++---- .../LoginAsCustomer/etc/adminhtml/di.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/events.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/menu.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/routes.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/system.xml | 14 ++++---- .../Magento/LoginAsCustomer/etc/config.xml | 4 +-- .../LoginAsCustomer/etc/frontend/di.xml | 8 ++--- .../LoginAsCustomer/etc/frontend/events.xml | 8 ++--- .../LoginAsCustomer/etc/frontend/routes.xml | 8 ++--- .../Magento/LoginAsCustomer/etc/module.xml | 10 +++--- .../LoginAsCustomer/etc/webrestrictions.xml | 6 ++-- .../Magento/LoginAsCustomer/registration.php | 8 ++--- .../layout/loginascustomer_guest_convert.xml | 8 ++--- .../layout/loginascustomer_login_grid.xml | 6 ++-- .../loginascustomer_login_grid_block.xml | 8 ++--- .../layout/loginascustomer_login_index.xml | 8 ++--- .../layout/loginascustomer_login_manual.xml | 6 ++-- .../view/adminhtml/templates/convert.phtml | 6 ++-- .../adminhtml/ui_component/customer_form.xml | 8 ++--- .../ui_component/customer_listing.xml | 8 ++--- .../ui_component/manual_store_form.xml | 10 +++--- .../ui_component/sales_order_grid.xml | 8 ++--- .../layout/loginascustomer_login_proceed.xml | 8 ++--- .../view/frontend/templates/login.phtml | 8 ++--- .../view/frontend/web/js/login.js | 4 +-- 55 files changed, 221 insertions(+), 325 deletions(-) diff --git a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php index 1d3f27f4ae70d..8923f2851e6fa 100755 --- a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php +++ b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php @@ -1,12 +1,10 @@ getCustomerId(); $data = []; - $canModify = $customerId && $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + $canModify = $customerId && $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); if ($canModify) { $data = [ 'label' => __('Login As Customer'), diff --git a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php index 1a6fa5f211d73..8a3251fe8abc8 100755 --- a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php +++ b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php @@ -1,12 +1,10 @@ moduleManager->isEnabled('Magefan_GuestToCustomer')) { + if ($this->moduleManager->isEnabled('Magento_GuestToCustomer')) { $this->_redirect('mfguesttocustomer/order/convert', [ 'order_id' => $this->getRequest()->getParam('order_id') ]); diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php index b2c43d8f04771..868a6d9ab00d0 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php @@ -1,12 +1,10 @@ _authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_log'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php index 2e5f4538c9c7b..2c006c421a38c 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php @@ -1,12 +1,10 @@ _objectManager; - $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Login::class); } /** * Login as customer log @@ -43,10 +40,10 @@ public function execute() return; } - $this->login->deleteNotUsed(); + $this->loginModel->deleteNotUsed(); $this->_view->loadLayout(); - $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); + $this->_setActiveMenu('Magento_LoginAsCustomer::login_log'); $title = __('Login As Customer Log '); $this->_view->getPage()->getConfig()->getTitle()->prepend($title); $this->_addBreadcrumb($title, $title); @@ -60,6 +57,6 @@ public function execute() */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_log'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php index 2d6e1b2d757aa..b701e8f086da0 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php @@ -1,21 +1,19 @@ loginModel = $loginModel ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Login::class); $this->authSession = $authSession ?: $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class); $this->storeManager = $storeManager ?: $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); $this->url = $url ?: $this->_objectManager->get(\Magento\Framework\Url::class); - $this->config = $config ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Config::class); + $this->config = $config ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Config::class); } /** * Login as customer action @@ -124,6 +122,6 @@ public function execute() */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php index 8e10abf6b15a4..e19f21257a4ab 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php @@ -1,16 +1,14 @@ _view->loadLayout(); - $this->_setActiveMenu('Magefan_LoginAsCustomer::login_button'); + $this->_setActiveMenu('Magento_LoginAsCustomer::login_button'); $title = __('Store View To Login In '); $this->_view->getPage()->getConfig()->getTitle()->prepend($title); $this->_addBreadcrumb($title, $title); @@ -34,6 +32,6 @@ public function execute() */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php b/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php index 9c50d865827d0..93209ca6703bc 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php @@ -1,11 +1,9 @@ _objectManager; - $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Login::class); } /** * Login as customer action @@ -46,11 +43,11 @@ public function execute() try { /* Log in */ $login->authenticateCustomer(); - $this->messageManager->addSuccess( + $this->messageManager->addSuccessMessage( __('You are logged in as customer: %1', $login->getCustomer()->getName()) ); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } $this->_redirect('*/*/proceed'); @@ -58,22 +55,22 @@ public function execute() /** * Init login info - * @return false || \Magefan\LoginAsCustomer\Model\Login + * @return false || \Magento\LoginAsCustomer\Model\Login */ protected function _initLogin() { $secret = $this->getRequest()->getParam('secret'); if (!$secret) { - $this->messageManager->addError(__('Cannot login to account. No secret key provided.')); + $this->messageManager->addErrorMessage(__('Cannot login to account. No secret key provided.')); return false; } - $login = $this->login->loadNotUsed($secret); + $login = $this->loginModel->loadNotUsed($secret); if ($login->getId()) { return $login; } else { - $this->messageManager->addError(__('Cannot login to account. Secret key is not valid.')); + $this->messageManager->addErrorMessage(__('Cannot login to account. Secret key is not valid.')); return false; } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php b/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php index 592704f27c63e..e44d1b46e1c3e 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php @@ -1,11 +1,9 @@ _feedUrl . 'domain/' . urlencode($domain); $modulesParams = []; - foreach ($this->getMagefanModules() as $key => $module) { - $key = str_replace('Magefan_', '', $key); + foreach ($this->getMagentoModules() as $key => $module) { + $key = str_replace('Magento_', '', $key); $modulesParams[] = $key . ',' . $module['setup_version']; } @@ -100,15 +98,15 @@ public function getFeedUrl() } /** - * Get Magefan Modules Info + * Get Magento Modules Info * * @return $this */ - protected function getMagefanModules() + protected function getMagentoModules() { $modules = []; foreach ($this->_moduleList->getAll() as $moduleName => $module) { - if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) { + if (strpos($moduleName, 'Magento_') !== false && $this->_moduleManager->isEnabled($moduleName)) { $modules[$moduleName] = $module; } } diff --git a/app/code/Magento/LoginAsCustomer/Model/Config.php b/app/code/Magento/LoginAsCustomer/Model/Config.php index 565be294cbe64..df69868fabb4b 100644 --- a/app/code/Magento/LoginAsCustomer/Model/Config.php +++ b/app/code/Magento/LoginAsCustomer/Model/Config.php @@ -1,12 +1,10 @@ _init('Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + $this->_init(\Magento\LoginAsCustomer\Model\ResourceModel\Login::class); } /** diff --git a/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php b/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php index 80c79ee02aff1..9d7b26a2d6677 100644 --- a/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php +++ b/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php @@ -1,12 +1,10 @@ _init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + $this->_init(\Magento\LoginAsCustomer\Model\Login::class, \Magento\LoginAsCustomer\Model\ResourceModel\Login::class); } } diff --git a/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php b/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php index 5b35d4bc5db60..1352c5417cb72 100755 --- a/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php +++ b/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php @@ -1,17 +1,15 @@ _feedFactory = $feedFactory; @@ -48,7 +46,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) { if ($this->_backendAuthSession->isLoggedIn()) { $feedModel = $this->_feedFactory->create(); - /* @var $feedModel \Magefan\LoginAsCustomer\Model\AdminNotificationFeed */ + /* @var $feedModel \Magento\LoginAsCustomer\Model\AdminNotificationFeed */ $feedModel->checkUpdate(); } } diff --git a/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php b/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php index 1f48092ed8c6e..f0448db828032 100644 --- a/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php +++ b/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php @@ -1,12 +1,10 @@ authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + return $this->authorization->isAllowed('Magento_LoginAsCustomer::login_button'); } } diff --git a/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php b/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php index af4e2ea068389..c31d005991c62 100755 --- a/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php +++ b/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php @@ -1,12 +1,10 @@ getIdxName('magefan_login_as_customer', ['admin_id']), ['admin_id'] )->setComment( - 'Magefan Login As Customer Table' + 'Magento Login As Customer Table' ); $installer->getConnection()->createTable($table); diff --git a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php index ffff4d62e4552..b82f64348eaf1 100644 --- a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php +++ b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php @@ -1,12 +1,10 @@ _authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + $hidden = !$this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); foreach ($dataSource['data']['items'] as &$item) { if (!empty($item[$this->sourceColumnName])) { $item[$this->getData('name')]['edit'] = [ diff --git a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php index f64d7a0de8368..c8a18c54066f3 100644 --- a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php +++ b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php @@ -1,12 +1,10 @@ @@ -12,15 +10,15 @@ - - - + + + - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml index 8bdf5098b235b..df46bb8d8676f 100644 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml index 6d927c6281e97..ffd363942a45d 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml index a1bc272745d01..8118e3da55cf4 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml index fae735f6e5b94..1b9d9b8850f5e 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml @@ -1,16 +1,14 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml index 4ae047d412616..d7914aea7d5c7 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml @@ -1,10 +1,8 @@ @@ -16,11 +14,11 @@ separator-top magefan - Magefan_LoginAsCustomer::config_section + Magento_LoginAsCustomer::config_section - Magefan\LoginAsCustomer\Block\Adminhtml\System\Config\Form\Info + Magento\LoginAsCustomer\Block\Adminhtml\System\Config\Form\Info @@ -28,7 +26,7 @@ - Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField + Magento\Community\Block\Adminhtml\System\Config\Form\ProductKeyField @@ -42,7 +40,7 @@ - Magefan\LoginAsCustomer\Model\Config\Source\StoreViewLogin + Magento\LoginAsCustomer\Model\Config\Source\StoreViewLogin - + diff --git a/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml b/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml index d3ed1dea6bd1f..93379367e43d1 100644 --- a/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml +++ b/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml b/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml index dd0bb9468061d..62604aff90647 100755 --- a/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml +++ b/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml @@ -1,16 +1,14 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/module.xml b/app/code/Magento/LoginAsCustomer/etc/module.xml index 4247a85af864e..f6fde8a2176db 100755 --- a/app/code/Magento/LoginAsCustomer/etc/module.xml +++ b/app/code/Magento/LoginAsCustomer/etc/module.xml @@ -1,18 +1,16 @@ - + - + diff --git a/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml b/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml index f677421814b2c..5d909de63d123 100644 --- a/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml +++ b/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml @@ -1,10 +1,8 @@ diff --git a/app/code/Magento/LoginAsCustomer/registration.php b/app/code/Magento/LoginAsCustomer/registration.php index ad600c507c432..ac43a6d812e9b 100755 --- a/app/code/Magento/LoginAsCustomer/registration.php +++ b/app/code/Magento/LoginAsCustomer/registration.php @@ -1,13 +1,11 @@ @@ -15,7 +13,7 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml index 21c82747bce6d..6f400c0e5c601 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml @@ -1,10 +1,8 @@ diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml index 95163c14f162d..8f38fab2e2e7a 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml @@ -1,10 +1,8 @@ @@ -13,7 +11,7 @@ subscriberGrid - Magefan\LoginAsCustomer\Model\ResourceModel\Login\Grid\Collection + Magento\LoginAsCustomer\Model\ResourceModel\Login\Grid\Collection created_at desc 1 diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml index 20ed90068a5d5..478df23cf0792 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml @@ -1,10 +1,8 @@ @@ -12,7 +10,7 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml index a8dde7c0ddd4c..a4a1bd6c92bdf 100644 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml @@ -1,10 +1,8 @@ diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml index 9b1fed36369bc..82988c801ef7d 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml @@ -1,16 +1,14 @@
- Magefan\LoginAsCustomer\Block\Adminhtml\Customer\Edit\Login + Magento\LoginAsCustomer\Block\Adminhtml\Customer\Edit\Login
diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml index 8d490051438e7..27bd103378f93 100644 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml @@ -1,15 +1,13 @@ - + Login diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml index e12843dd3db92..b324143a7294a 100644 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml @@ -1,10 +1,8 @@
@@ -17,7 +15,7 @@ -