Add ACP shell and JWT claims
This commit is contained in:
24
api/src/EventSubscriber/JwtCreatedSubscriber.php
Normal file
24
api/src/EventSubscriber/JwtCreatedSubscriber.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user