I've added this listener
acme_api.event.jwt_created_listener:
class: AppBundle\EventListener\JWTCreatedListener
tags:
- { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }
but the event is not dispatched (is not visible) from symfony's profiler. I am trying to use it to customize the token expiration time. The method onJWTCreated
is not called!
As shown in your previous question Why my jwt tokens never expire?, you are not using the bundle through the Symfony security system (config), but deliver tokens "manually" using low level APIs from your controller.
The JWTCreatedEvent is dispatched by JWTManager ('lexik_jwt_authentication.jwt_manager` service). If you want the event to be dispatched, consider using that service instead of using the encoder directly (which may become private in the next major, thus not accessible from a controller unless injected).