drui0508 2013-07-09 10:48
浏览 28
已采纳

当用户未登录安全区域时重定向的挂钩/扩展类 - Symfony2

I have extended these three classes to hook-in and perform a different action if certain conditions are met:

DefaultAuthenticationFailureHandler
DefaultAuthenticationSuccessHandler
DefaultLogoutSuccessHandler

Everything works great and they all use more or less the same code and services.yml configuration.

I now need to do exactly the same and hook-in to the event/class/whatever it is that performs the redirect when an attempt is made to access a page in the secure area.

So I don't need this for when they fail the login attempt (as one of the ones above does that), but I need to hook-in on when they access a page that's in the secure area and that then usually redirects to the login page (but I want to intercept that and perform an action before the redirect).

Ideally the answer would be something like this:

"Just extend the DefaultAuthenticationRequired class in the same way"

...but I don't think it's that easy

  • 写回答

1条回答 默认 最新

  • dousao6260 2013-07-10 03:13
    关注

    Create an event and dispatch it in an extended AccessListener.

    This way you can "hook" multiple new classes for logging ... whatever when your access-listener detects a protected resource.

    Listeners for that event could then be registered using a self-defined container tag.

    Read the documentation of the EventDispatcher component.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口