1

How can I add logic to Symfony2's authentication method?

for example, blocking one's login attempts after certain amount of failed logins.

tamir
  • 3,207
  • 2
  • 33
  • 51

2 Answers2

1

You can do it in an authentication handler. Here is an example of an authentication handler which you can adapt to your needs.

Community
  • 1
  • 1
Elnur Abdurrakhimov
  • 44,533
  • 10
  • 148
  • 133
0

You should define service that implements Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface and in method onAuthenticationFailure() you can increase attribute which handle number of attempts. If number reach limit you just switch user attribute enabled to false

kuboslav
  • 1,430
  • 5
  • 16
  • 31