mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Make LogoutLoggerEventSubscriber an event listener
This commit is contained in:
parent
58b2c2bd69
commit
4bec8efea1
1 changed files with 4 additions and 9 deletions
|
@ -25,12 +25,14 @@ namespace App\EventSubscriber\LogSystem;
|
||||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Services\LogSystem\EventLogger;
|
use App\Services\LogSystem\EventLogger;
|
||||||
|
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||||
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
use Symfony\Component\Security\Http\Event\LogoutEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This handler logs to event log, if a user logs out.
|
* 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 EventLogger $logger;
|
||||||
protected bool $gpdr_compliance;
|
protected bool $gpdr_compliance;
|
||||||
|
@ -41,7 +43,7 @@ class LogoutLoggerEventSubscriber implements \Symfony\Component\EventDispatcher\
|
||||||
$this->gpdr_compliance = $gpdr_compliance;
|
$this->gpdr_compliance = $gpdr_compliance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke(LogoutEvent $event)
|
public function __invoke(LogoutEvent $event): void
|
||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
$token = $event->getToken();
|
$token = $event->getToken();
|
||||||
|
@ -58,11 +60,4 @@ class LogoutLoggerEventSubscriber implements \Symfony\Component\EventDispatcher\
|
||||||
|
|
||||||
$this->logger->logAndFlush($log);
|
$this->logger->logAndFlush($log);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents(): array
|
|
||||||
{
|
|
||||||
return [\Symfony\Component\Security\Http\Event\LogoutEvent::class => ''];
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue