Symfony的探查器中不存在lexik_jwt_authentication.on_jwt_created [英] The `lexik_jwt_authentication.on_jwt_created` is not present in Symfony's profiler

查看:113
本文介绍了Symfony的探查器中不存在lexik_jwt_authentication.on_jwt_created的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经添加了此侦听器

acme_api.event.jwt_created_listener:
    class: AppBundle\EventListener\JWTCreatedListener
    tags:
        - { name: kernel.event_listener, event: lexik_jwt_authentication.on_jwt_created, method: onJWTCreated }

,但是不会从symfony的探查器中调度(不可见)该事件.我试图用它来定制令牌的到期时间.方法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.

JWTCreatedEvent由JWTManager调度("lexik_jwt_authentication.jwt_manager"服务).如果您希望事件被调度,请考虑使用该服务,而不是直接使用编码器(编码器在下一个专业中可能变为私有,因此除非被注入,否则无法从控制器访问).

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

这篇关于Symfony的探查器中不存在lexik_jwt_authentication.on_jwt_created的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆