Symfony2 - 扩展 RememberMe 成功处理程序 [英] Symfony2 - Extend RememberMe Success Handler

查看:29
本文介绍了Symfony2 - 扩展 RememberMe 成功处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某人刚刚使用 Symfony2 中的记住我功能登录后执行一个小的 PHP 操作.

I want to perform one small PHP action after someone has just been logged in with the Remember Me feature in Symfony2.

我见过这个,但不知道如何扩展它:http://api.symfony.com/2.3/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.html

I have seen this but not sure how to extend it: http://api.symfony.com/2.3/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.html

我不知道该怎么做(不编辑核心代码,这当然不好).我已将自己的代码添加到 AuthenticationSuccess 处理程序中,以便他们在通过提交表单登录时使用,但这只是通过创建服务并指定如下示例所示,但我没有看到 RememberMe 成功处理程序的选项,我可以看到此处的完整选项列表:http://symfony.com/doc/current/参考/配置/security.html.

I'm not sure how to go about this (without editing the core code which of course wouldn't be good). I have added my own code to an AuthenticationSuccess handler for when they login via submitting a form, but that is simply by creating a service and specifying like example below, but I don't see an option for the RememberMe success handler and I can see the full list of options here: http://symfony.com/doc/current/reference/configuration/security.html.

security:
    firewalls:
        secure_area:
            form_login:
                success_handler: some.service.id

我该怎么做?提前致谢.

How do I do this? Thanks in advance.

推荐答案

通过记住我身份验证的用户将获得角色 IS_AUTHENTICATED_REMEMBERED.

Users authenticated via remember me receive the role IS_AUTHENTICATED_REMEMBERED.

在正常的成功处理程序中检查您的用户为此角色的角色并执行所需的操作.

Check your user's roles for this role in the normal success handler and perform the desired action.

这篇关于Symfony2 - 扩展 RememberMe 成功处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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