overshadow
overshadow

Reputation: 988

Symfony2: How To Perform Custom Validation Before Authentication?

I am using Symfony login system which is symfony will take care of the entire login process for me as long as I got the configuration (firewall) correctly.

How can I perform some custom validation before it performs the authentication process? For example, check the length of username, validate captcha code and etc. If one of the requirement does not meet, I need to stop further action (authentication) and return error message.

I know there is some authentication handlers like authentication success handler or authentication failure handler which allow you to do some action upon authentication successful or failure. Is there any handler like this that allow me put my custom code before performing authentication action?

Upvotes: 0

Views: 431

Answers (1)

Amine Matmati
Amine Matmati

Reputation: 283

You can create a custom authenticator, this is all you need:

http://symfony.com/doc/current/cookbook/security/custom_password_authenticator.html#the-password-authenticator

Upvotes: 1

Related Questions