问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/29555811/fos-user-bundle-get-post-data-from-login