FOS User Bundle get POST Data from Login

落爺英雄遲暮 提交于 2019-12-11 10:38:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!