Add ACP shell and JWT claims

This commit is contained in:
Micha
2025-12-24 13:29:28 +01:00
parent 193273c843
commit 5ed9d0e1f8
6 changed files with 166 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\EventSubscriber;
use App\Entity\User;
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: 'lexik_jwt_authentication.on_jwt_created')]
class JwtCreatedSubscriber
{
public function __invoke(JWTCreatedEvent $event): void
{
$user = $event->getUser();
if (!$user instanceof User) {
return;
}
$payload = $event->getData();
$payload['user_id'] = $user->getId();
$payload['username'] = $user->getUsername();
$event->setData($payload);
}
}