fix: missing session item for mercure alert topic
This commit is contained in:
@@ -12,15 +12,12 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
final class IndexController extends AbstractController
|
final class IndexController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly DownloadRepository $downloadRepository,
|
|
||||||
private readonly Tmdb $tmdb,
|
private readonly Tmdb $tmdb,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[Route('/', name: 'app_index')]
|
#[Route('/', name: 'app_index')]
|
||||||
public function index(Request $request): Response
|
public function index(Request $request): Response
|
||||||
{
|
{
|
||||||
$request->getSession()->set('mercure_alert_topic', 'alerts_' . uniqid());
|
|
||||||
|
|
||||||
return $this->render('index/index.html.twig', [
|
return $this->render('index/index.html.twig', [
|
||||||
'active_downloads' => $this->getUser()->getActiveDownloads(),
|
'active_downloads' => $this->getUser()->getActiveDownloads(),
|
||||||
'recent_downloads' => $this->getUser()->getDownloads(),
|
'recent_downloads' => $this->getUser()->getDownloads(),
|
||||||
|
|||||||
21
src/User/Framework/EventListener/LoginSuccessListener.php
Normal file
21
src/User/Framework/EventListener/LoginSuccessListener.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Framework\EventListener;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
|
||||||
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Symfony\Component\Security\Core\Event\AuthenticationSuccessEvent;
|
||||||
|
|
||||||
|
final class LoginSuccessListener
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly RequestStack $requestStack,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
#[AsEventListener(event: 'security.authentication.success')]
|
||||||
|
public function setMercureTopics(AuthenticationSuccessEvent $event): void
|
||||||
|
{
|
||||||
|
// Set the unique Mercure topic name for the User's alerts
|
||||||
|
$this->requestStack->getSession()->set('mercure_alert_topic', 'alerts_' . uniqid());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user