security.user_checker
你可以在你的 bundle中重新定义 Symfony 的用户检查服务( ):
# services.yml
security.user_checker:
class: MyBundle\Checker\UserChecker
arguments: [ "@some.service", "%some.param%" ]
然后扩展 Symfony 的 UserChecker:
# UserChecker.php
use Symfony\Component\Security\Core\User\UserChecker as BaseUserChecker;
class UserChecker extends BaseUserChecker
{
public function checkPreAuth(UserInterface $user)
{
parent::checkPreAuth($user);
// your stuff
}
public function checkPostAuth(UserInterface $user)
{
parent::checkPostAuth($user);
// your stuff
}
}
该服务在身份验证过程中security.user_checker
被调用\Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider::authenticate()