mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Removed deprecated SessionInterface service
This commit is contained in:
parent
1cee1abe00
commit
b3ecee749e
4 changed files with 21 additions and 17 deletions
|
@ -28,20 +28,17 @@ use function in_array;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class RedirectController extends AbstractController
|
class RedirectController extends AbstractController
|
||||||
{
|
{
|
||||||
protected string $default_locale;
|
protected string $default_locale;
|
||||||
protected TranslatorInterface $translator;
|
protected TranslatorInterface $translator;
|
||||||
protected SessionInterface $session;
|
|
||||||
protected bool $enforce_index_php;
|
protected bool $enforce_index_php;
|
||||||
|
|
||||||
public function __construct(string $default_locale, TranslatorInterface $translator, SessionInterface $session, bool $enforce_index_php)
|
public function __construct(string $default_locale, TranslatorInterface $translator, bool $enforce_index_php)
|
||||||
{
|
{
|
||||||
$this->default_locale = $default_locale;
|
$this->default_locale = $default_locale;
|
||||||
$this->session = $session;
|
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->enforce_index_php = $enforce_index_php;
|
$this->enforce_index_php = $enforce_index_php;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ use App\Entity\LogSystem\UserLoginLogEntry;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Services\LogSystem\EventLogger;
|
use App\Services\LogSystem\EventLogger;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
|
@ -39,15 +40,15 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
final class LoginSuccessSubscriber implements EventSubscriberInterface
|
final class LoginSuccessSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
private TranslatorInterface $translator;
|
private TranslatorInterface $translator;
|
||||||
private FlashBagInterface $flashBag;
|
private RequestStack $requestStack;
|
||||||
private EventLogger $eventLogger;
|
private EventLogger $eventLogger;
|
||||||
private bool $gpdr_compliance;
|
private bool $gpdr_compliance;
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator, SessionInterface $session, EventLogger $eventLogger, bool $gpdr_compliance)
|
public function __construct(TranslatorInterface $translator, RequestStack $requestStack, EventLogger $eventLogger, bool $gpdr_compliance)
|
||||||
{
|
{
|
||||||
/** @var Session $session */
|
/** @var Session $session */
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->flashBag = $session->getFlashBag();
|
$this->requestStack = $requestStack;
|
||||||
$this->eventLogger = $eventLogger;
|
$this->eventLogger = $eventLogger;
|
||||||
$this->gpdr_compliance = $gpdr_compliance;
|
$this->gpdr_compliance = $gpdr_compliance;
|
||||||
}
|
}
|
||||||
|
@ -62,8 +63,11 @@ final class LoginSuccessSubscriber implements EventSubscriberInterface
|
||||||
$this->eventLogger->logAndFlush($log);
|
$this->eventLogger->logAndFlush($log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var Session $session */
|
||||||
|
$session = $this->requestStack->getSession();
|
||||||
|
$flashBag = $session->getFlashBag();
|
||||||
|
|
||||||
$this->flashBag->add('notice', $this->translator->trans('flash.login_successful'));
|
$flashBag->add('notice', $this->translator->trans('flash.login_successful'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,14 +56,11 @@ final class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
||||||
*/
|
*/
|
||||||
public const REDIRECT_TARGET = 'user_settings';
|
public const REDIRECT_TARGET = 'user_settings';
|
||||||
private Security $security;
|
private Security $security;
|
||||||
private FlashBagInterface $flashBag;
|
|
||||||
private HttpUtils $httpUtils;
|
private HttpUtils $httpUtils;
|
||||||
|
|
||||||
public function __construct(Security $security, SessionInterface $session, HttpUtils $httpUtils)
|
public function __construct(Security $security, HttpUtils $httpUtils)
|
||||||
{
|
{
|
||||||
/** @var Session $session */
|
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
$this->flashBag = $session->getFlashBag();
|
|
||||||
$this->httpUtils = $httpUtils;
|
$this->httpUtils = $httpUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +100,13 @@ final class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var Session $session */
|
||||||
|
$session = $request->getSession();
|
||||||
|
$flashBag = $session->getFlashBag();
|
||||||
|
|
||||||
//Show appropriate message to user about the reason he was redirected
|
//Show appropriate message to user about the reason he was redirected
|
||||||
if ($user->isNeedPwChange()) {
|
if ($user->isNeedPwChange()) {
|
||||||
$this->flashBag->add('warning', 'user.pw_change_needed.flash');
|
$flashBag->add('warning', 'user.pw_change_needed.flash');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (static::TFARedirectNeeded($user)) {
|
if (static::TFARedirectNeeded($user)) {
|
||||||
|
|
|
@ -40,16 +40,14 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface
|
||||||
private Security $security;
|
private Security $security;
|
||||||
private PermissionSchemaUpdater $permissionSchemaUpdater;
|
private PermissionSchemaUpdater $permissionSchemaUpdater;
|
||||||
private EntityManagerInterface $entityManager;
|
private EntityManagerInterface $entityManager;
|
||||||
private FlashBagInterface $flashBag;
|
|
||||||
private EventCommentHelper $eventCommentHelper;
|
private EventCommentHelper $eventCommentHelper;
|
||||||
|
|
||||||
public function __construct(Security $security, PermissionSchemaUpdater $permissionSchemaUpdater, EntityManagerInterface $entityManager, SessionInterface $session, EventCommentHelper $eventCommentHelper)
|
public function __construct(Security $security, PermissionSchemaUpdater $permissionSchemaUpdater, EntityManagerInterface $entityManager, EventCommentHelper $eventCommentHelper)
|
||||||
{
|
{
|
||||||
/** @var Session $session */
|
/** @var Session $session */
|
||||||
$this->security = $security;
|
$this->security = $security;
|
||||||
$this->permissionSchemaUpdater = $permissionSchemaUpdater;
|
$this->permissionSchemaUpdater = $permissionSchemaUpdater;
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
$this->flashBag = $session->getFlashBag();
|
|
||||||
$this->eventCommentHelper = $eventCommentHelper;
|
$this->eventCommentHelper = $eventCommentHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,11 +63,15 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface
|
||||||
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
|
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var Session $session */
|
||||||
|
$session = $event->getRequest()->getSession();
|
||||||
|
$flashBag = $session->getFlashBag();
|
||||||
|
|
||||||
if ($this->permissionSchemaUpdater->isSchemaUpdateNeeded($user)) {
|
if ($this->permissionSchemaUpdater->isSchemaUpdateNeeded($user)) {
|
||||||
$this->eventCommentHelper->setMessage('Automatic permission schema update');
|
$this->eventCommentHelper->setMessage('Automatic permission schema update');
|
||||||
$this->permissionSchemaUpdater->userUpgradeSchemaRecursively($user);
|
$this->permissionSchemaUpdater->userUpgradeSchemaRecursively($user);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
$this->flashBag->add('notice', 'user.permissions_schema_updated');
|
$flashBag->add('notice', 'user.permissions_schema_updated');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue