![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/UserBundle/EventListener/ |
<?php namespace Mautic\UserBundle\EventListener; use Mautic\CoreBundle\Helper\IpLookupHelper; use Mautic\CoreBundle\Model\AuditLogModel; use Mautic\UserBundle\Event\LoginEvent; use Mautic\UserBundle\UserEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class SecuritySubscriber implements EventSubscriberInterface { public function __construct( private IpLookupHelper $ipLookupHelper, private AuditLogModel $auditLogModel ) { } public static function getSubscribedEvents(): array { return [ UserEvents::USER_LOGIN => ['onSecurityInteractiveLogin', 0], ]; } public function onSecurityInteractiveLogin(LoginEvent $event): void { $userId = (int) $event->getUser()->getId(); $useName = $event->getUser()->getUsername(); $log = [ 'bundle' => 'user', 'object' => 'security', 'objectId' => $userId, 'action' => 'login', 'details' => ['username' => $useName], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest(), ]; $this->auditLogModel->writeToLog($log); } }