If you met problem login sensitive data as login account customer, admin with issues just happen on some account. You can visit this trick.
1. For Customer login:
Use core to test:
Go to file:
Magento\Customer\Controller\Account\LoginPost.php
Add this code behind function execute().
$this->session->loginById($customerId);
$this->session->regenerateId();
$customerId is your customer id would like to login.
Use plugin
Create di.xml:
Create file plugin:
Also, you can use another way as :
- event: capture event “
controller_action_predispatch_customer_account_loginpost"
- rewrite: override function execute via file:
Magento\Customer\Controller\Account\LoginPost
2. For Admin login:
Use core to test
Go to file:
Magento\Backend\Controller\Adminhtml\Auth\Login.php
Add this code behind function execute().
Another way same customer:
- Plugin: Use plugin for class \Magento\Backend\Model\Auth\Session.php with function isLoggedIn()
- Event:
controller_action_predispatch_adminhtml_auth_login
- Rewrite: Class Magento\Backend\Controller\Adminhtml\Auth\Login.php function execute().