FOS用户包从登录中获得POST数据[英] FOS User Bundle get POST Data from Login

本文是小编为大家收集整理的关于FOS用户包从登录中获得POST数据的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在尝试将新的Google Recaptcha集成到FOS用户捆绑登录中.

我已经成功地覆盖了登录模板和SecurityController表单fos fos loginAction()发生.

我面临的问题是,我无法从控制器中任何地方的登录表单访问发送帖子数据.我在loginAction()和checkAction()中尝试过,他们俩都没有在请求中使用帖子数据.

所以我猜想有一个服务,侦听器或其他行动或其他方面的东西,以便丢失帖子数据.

在哪里可以访问将从登录表单发送到服务器的帖子数据?

推荐答案

我喝了一杯咖啡并重新考虑了问题.

您可以访问已从登录表单发送的数据,并在登录事件上听取侦听器.这是我在services中配置的侦听器

project.LoginListener:
    class: namespace\Listener\LoginListener
    arguments: [@doctrine,@session,@security.context,@project.someService]
    tags:
        - { name: kernel.event_listener, event: security.interactive_login, method :onSecurityInteractiveLogin }

在侦听器中,您可以轻松地在请求的参数袋中访问已发送的数据.该请求可以通过侦听器中给出的事件访问.

本文地址:https://www.itbaoku.cn/post/2090829.html

问题描述

I'm trying to integrate the new Google recaptcha into the FOS User Bundle Login.

I've successfully overwritten the login template and the SecurityController form FOS where the loginAction() happens.

The problem I'm facing is that I can't access the send POST Data from the Login Form anywhere in the Controller. I tried it in the loginAction() and in the checkAction(), neither of them had the POST Data in the request.

So I'm guessing that there's a service, listener or something else that does a redirect or something else so that the POST data get lost.

Where can I access the POST Data that will be send to the server from the Login Form?

推荐答案

I found the answer within my source code after I drank a cup of coffee and rethought the problem.

You can access the Data, that has been sent from the login Form, with a listener that listens on the login event. This is the listener I configured in my services.yml

project.LoginListener:
    class: namespace\Listener\LoginListener
    arguments: [@doctrine,@session,@security.context,@project.someService]
    tags:
        - { name: kernel.event_listener, event: security.interactive_login, method :onSecurityInteractiveLogin }

Within the listener you can easily access the sent data in the paramter bag of the request. The request is accessable through the event that's given within the listener.