FOS用户捆绑包从登录名获取POST数据 [英] FOS User Bundle get POST Data from Login
问题描述
我正在尝试将新的Google Recaptcha集成到FOS用户捆绑包登录中.
I'm trying to integrate the new Google recaptcha into the FOS User Bundle Login.
我已经成功覆盖了loginAction()
所在的登录模板和SecurityController形式的FOS.
I've successfully overwritten the login template and the SecurityController form FOS where the loginAction()
happens.
我面临的问题是我无法从Controller的任何位置的登录表单"访问发送POST数据.我在loginAction()
和checkAction()
中进行了尝试,他们两个都没有在请求中添加POST数据.
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.
因此,我猜测是有一个服务,侦听器或执行重定向的其他操作,或其他导致POST数据丢失的操作.
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.
我在哪里可以访问将从登录表单发送到服务器的POST数据?
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.
您可以使用侦听登录事件的侦听器访问从登录表单发送的数据.这是我在services.yml中配置的监听器
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.
这篇关于FOS用户捆绑包从登录名获取POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!