0

I'm trying to count failed and successful logins for my users. For that, I simply want to increase the respective counter in the datebase whenever an authentication attempt succeeds or fails. But I want to keep the default behavior without reinventing it.

So I followed this post: Symfony2 hold behavior when extending DefaultAuthenticationSuccessHandler

But apparently I cannot add any parameters to the constructor of my subclass of DefaultAuthenticationSuccessHandler or Symfony complains that the argument types are wrong.

How can I inject my user management service as a constructor parameter??

EDIT: Actually, the problem seems to be a little bit different! I have the following line in my services.yml:

services:
 security.authentication.success_handler:
  class: %security.authentication.success_handler.class%
  arguments: [@my_stuff.my_user_management_service, @security.http_utils, {}]

But the second argument passed to the constructor is an array containing the options like "login_path". But it's supposed to be an instance of HttpUtils. I'm confused...

Community
  • 1
  • 1
user2323470
  • 173
  • 8

1 Answers1

0

I figured it out by myself: the order of the parameters is important. I had to move my_stuff.my_user_management_service to the end of the parameter array like so:

arguments: [@security.http_utils, {}, @my_stuff.my_user_management_service]

I don't really understand why, though. There is something wrong with the parameter injection. Maybe someone has some insight??

user2323470
  • 173
  • 8