<?php
namespace App\Security;
use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent;
use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTAuthenticatedEvent;
use Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationSuccessHandler;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
class JWTAuthenticationSuccessHandler extends AuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
{
private $router;
/**
* @param AuthenticationSuccessEvent $event
*/
public function onAuthenticationSuccessResponse(AuthenticationSuccessEvent $event)
{
$data = $event->getData();
$user = $event->getUser();
if (!$user instanceof UserInterface) {
return;
}
$data['user'] = array(
'roles' => $user->getRoles(),
'id' => $user->getId(),
'username' => $user->getUsername(),
'email' => $user->getEmail(),
'telehone' => $user->getTelefone(),
'profiles' => $user->getProfiles(),
'wareHouse' => $user->getWareHouse(),
'lastActivity' => $user->getLastActivity(),
);
$event->setData($data);
}
}