What are the steps in magento 2 to use the events to capture the admin login success or admin login fail.
Asked
Active
Viewed 1,694 times
1 Answers
3
You can observe the following events:
- admin user login success:
backend_auth_user_login_success - admin user login fail:
backend_auth_user_login_failed
In a module you can create the following etc/events.xml file:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="backend_auth_user_login_success">
<observer name="my_custom_login_success_observer" instance="Vendor\Module\Observer\AdminLoginSucceeded" />
</event>
<event name="backend_auth_user_login_failed">
<observer name="my_custom_login_failed_observer" instance="Vendor\Module\Observer\AdminLoginFailed" />
</event>
</config>
Then you can create the following observers:
Observer/AdminLoginSucceeded.phpObserver/AdminLoginFailed.php
Raphael at Digital Pianism
- 70,385
- 34
- 188
- 352