简体   繁体   English

Symfony2-扩展RememberMe成功处理程序

[英]Symfony2 - Extend RememberMe Success Handler

I want to perform one small PHP action after someone has just been logged in with the Remember Me feature in Symfony2. 我想在有人使用Symfony2中的“记住我”功能登录后执行一个小的PHP操作。

I have seen this but not sure how to extend it: http://api.symfony.com/2.3/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.html 我已经看到了,但是不确定如何扩展它: http : //api.symfony.com/2.3/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.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 . 我将自己的代码添加到AuthenticationSuccess处理程序中,以供他们通过提交表单登录时使用,但这仅是通过创建服务并指定以下示例,但我没有看到RememberMe成功处理程序的选项,我可以看到此处提供了完整的选项列表: 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. 提前致谢。

Users authenticated via remember me receive the role IS_AUTHENTICATED_REMEMBERED . 通过记住我进行身份验证的用户将获得角色IS_AUTHENTICATED_REMEMBERED

Check your user's roles for this role in the normal success handler and perform the desired action. 在正常成功处理程序中,检查用户的角色是否具有此角色,然后执行所需的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM