mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-01 05:54:32 +02:00
Fixed service wiring configuration
This commit is contained in:
parent
98dc553938
commit
f63b6d7207
14 changed files with 29 additions and 35 deletions
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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.
|
||||
*/
|
||||
#[AsEventListener]
|
||||
final class LogLogoutEventEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
|
||||
{
|
||||
public function __construct(protected EventLogger $logger, protected bool $gpdr_compliance)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(LogoutEvent $event): void
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$token = $event->getToken();
|
||||
|
||||
if (!$token instanceof \Symfony\Component\Security\Core\Authentication\Token\TokenInterface) {
|
||||
return;
|
||||
}
|
||||
|
||||
$log = new UserLogoutLogEntry($request->getClientIp(), $this->gpdr_compliance);
|
||||
$user = $token->getUser();
|
||||
if ($user instanceof User) {
|
||||
$log->setTargetElement($user);
|
||||
}
|
||||
|
||||
$this->logger->logAndFlush($log);
|
||||
}
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['' => ''];
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
|||
*/
|
||||
final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(private readonly RequestStack $requestStack, private readonly EventLogger $eventLogger, private readonly bool $gpdr_compliant)
|
||||
public function __construct(private readonly RequestStack $requestStack, private readonly EventLogger $eventLogger, private readonly bool $gdpr_compliance)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
|||
|
||||
private function addLog(string $type, SecurityEvent $event): void
|
||||
{
|
||||
$anonymize = $this->gpdr_compliant;
|
||||
$anonymize = $this->gdpr_compliance;
|
||||
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
if ($request instanceof \Symfony\Component\HttpFoundation\Request) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue