简体   繁体   English

Symfony2 FosUser覆盖login_check

[英]Symfony2 FosUser override login_check

I'm working with Symfony and FosUserBundle and I need to insert a log in my database if login is ok and before the redirection to my secured area. 我正在使用SymfonyFosUserBundle ,如果登录FosUserBundle并且需要重定向到安全区域,则需要在数据库中插入日志。

I already overrode SecurityController for loginAction , but where can I insert my log ? 我已经覆盖了SecurityControllerloginAction ,但是我可以在哪里插入日志?

I don't think it's in loginAction , but I don't know how can I override login_check ? 我不认为它在loginAction ,但是我不知道如何覆盖login_check

Any ideas ? 有任何想法吗 ?

You can doing the work indirectly with symfony layer framework. 您可以使用symfony层框架间接进行工作。 If it's good for you that use symfony you can : 如果使用symfony对您有利,则可以:

  • use the DefaultAuthenticationSuccessHandler class symfony and read this : DefaultAuthenticationSuccessHandler 使用DefaultAuthenticationSuccessHandler类symfony并阅读以下内容: DefaultAuthenticationSuccessHandler
  • declare a service symfony with function 'onAuthenticationSuccess' 声明一个带有功能'onAuthenticationSuccess'的服务symfony

After that you can work with all symfony tools for logging all of you want. 之后,您就可以使用所有symfony工具记录所需的所有信息。

I already use this method with FOSUserBundle. 我已经在FOSUserBundle中使用了此方法。

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

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