tamir
tamir

Reputation: 3297

Symfony2 customize the authentication method

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

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

Upvotes: 1

Views: 1767

Answers (2)

Elnur Abdurrakhimov
Elnur Abdurrakhimov

Reputation: 44831

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

Upvotes: 1

kuboslav
kuboslav

Reputation: 1460

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

Upvotes: 0

Related Questions