mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-03 05:55:16 +01:00
Make LogoutLoggerEventSubscriber an event listener
This commit is contained in:
@@ -25,12 +25,14 @@ namespace App\EventSubscriber\LogSystem;
|
||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
||||
|
||||
/**
|
||||
* This handler logs to event log, if a user logs out.
|
||||
*/
|
||||
class LogoutLoggerEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
|
||||
#[AsEventListener]
|
||||
final class LogLogoutEventListener
|
||||
{
|
||||
protected EventLogger $logger;
|
||||
protected bool $gpdr_compliance;
|
||||
@@ -41,7 +43,7 @@ class LogoutLoggerEventSubscriber implements \Symfony\Component\EventDispatcher\
|
||||
$this->gpdr_compliance = $gpdr_compliance;
|
||||
}
|
||||
|
||||
public function __invoke(LogoutEvent $event)
|
||||
public function __invoke(LogoutEvent $event): void
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$token = $event->getToken();
|
||||
@@ -58,11 +60,4 @@ class LogoutLoggerEventSubscriber implements \Symfony\Component\EventDispatcher\
|
||||
|
||||
$this->logger->logAndFlush($log);
|
||||
}
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [\Symfony\Component\Security\Http\Event\LogoutEvent::class => ''];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user