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:
Add this code behind function execute().


$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:

2. For Admin login:

Use core to test

Go to file:
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().