The `lexik_jwt_authentication.on_jwt_created` is not present in Symfony's profiler

陌路散爱 提交于 2019-12-13 03:36:04

问题


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:


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



来源:https://stackoverflow.com/questions/45617269/the-lexik-jwt-authentication-on-jwt-created-is-not-present-in-symfonys-profil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!