简体   繁体   中英

Symfony 3, Guard & Handlers

Since the new component Guard from Symfony I've started playing a little with it to learn it better and see what things it changes. I've read the documentation from sf website to see what it brings and changes and i was wondering based on this example: Let's say we create a login attempt counter that at some point will disable the user until password reset. Of course for this we would use the login failure handler. But since guard should make everything easier i was wondering if we still need that handler or we just put a bit of logic in the onAuthenticationFailure / onAuthenticationSuccess / checkCredentials to do certain tasks like saving some info into database about the failed login etc and how much code should go in there.

The new Guard is aimed to ease the implementation of custom authentication patterns such as yours.

It is likely to be enough for most of the case even complex ones.

However, try to extract your custom processing, logging, etc. from your Guard and inject them to improve the maintainability of it.

Take a close look to GuardAuthenticatorInterface.php to find where and when in the process you have to set up your requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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