如何在Symfony2中收听“记住我"重新认证事件? [英] How can I listen for “remember me” reauthentication events in Symfony2?

查看:75
本文介绍了如何在Symfony2中收听“记住我"重新认证事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用正常"身份验证-而不是记住我"身份验证-我可以设置成功和失败处理程序,并将其添加到security.yml文件中:

Using "normal" — not "remember me" authentication — I can set a success and failure handlers, adding this to the security.yml file:

form_login:
    # ...
    success_handler: authentication_handler
    failure_handler: authentication_handler

但是,当用户会话期满并且使用记住我" cookie再次进行重新认证时,我找不到监听记住我"重新认证的方法.关于如何实现此目标的任何想法?

But I couldn't find a way for listening for "remember me" reauthentication, when a user's session is expired and a "remember me" cookie is used to reauthenticate again. Any ideas on how can I achieve this?

推荐答案

Symfony\Component\Security\Http\Firewall\RememberMeListener.php @line:77).

Create a Listener for the security.interactive_login event. That gets triggered on both simple and "remember me" logins (see Symfony\Component\Security\Http\Firewall\RememberMeListener.php @line:77).

在侦听器中,您可以通过检查cookie来将两者分开. 您可以在此处找到更多信息.

In the listener you can separate the two by checking the cookie. You can find more about the listener here.

这篇关于如何在Symfony2中收听“记住我"重新认证事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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