The `lexik_jwt_authentication.on_jwt_created` is n

2019-08-20 02:39发布

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!

1条回答
放荡不羁爱自由
2楼-- · 2019-08-20 03:32

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).

查看更多
登录 后发表回答