|
5 | 5 | use Lexik\Bundle\JWTAuthenticationBundle\Encoder\JWTEncoderInterface;
|
6 | 6 | use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTCreatedEvent;
|
7 | 7 | use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTDecodedEvent;
|
| 8 | +use Lexik\Bundle\JWTAuthenticationBundle\Event\JWTEncodedEvent; |
8 | 9 | use Lexik\Bundle\JWTAuthenticationBundle\Events;
|
9 | 10 | use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
10 | 11 | use Symfony\Component\HttpFoundation\Request;
|
11 | 12 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
12 | 13 | use Symfony\Component\Security\Core\User\UserInterface;
|
13 | 14 | use Symfony\Component\PropertyAccess\PropertyAccess;
|
| 15 | + |
14 | 16 | /**
|
15 | 17 | * JWTManager
|
16 | 18 | *
|
@@ -67,10 +69,15 @@ public function create(UserInterface $user)
|
67 | 69 |
|
68 | 70 | $this->addUserIdentityToPayload($user, $payload);
|
69 | 71 |
|
70 |
| - $event = new JWTCreatedEvent($payload, $user, $this->request); |
71 |
| - $this->dispatcher->dispatch(Events::JWT_CREATED, $event); |
| 72 | + $jwtCreatedEvent = new JWTCreatedEvent($payload, $user, $this->request); |
| 73 | + $this->dispatcher->dispatch(Events::JWT_CREATED, $jwtCreatedEvent); |
| 74 | + |
| 75 | + $jwtString = $this->jwtEncoder->encode($jwtCreatedEvent->getData()); |
| 76 | + |
| 77 | + $jwtEncodedEvent = new JWTEncodedEvent($jwtString); |
| 78 | + $this->dispatcher->dispatch(Events::JWT_ENCODED, $jwtEncodedEvent); |
72 | 79 |
|
73 |
| - return $this->jwtEncoder->encode($event->getData()); |
| 80 | + return $jwtString; |
74 | 81 | }
|
75 | 82 |
|
76 | 83 | /**
|
|
0 commit comments