我做了一个从DefaultAuthenticationSuccessHandler扩展的子类,以便在身份验证过程中添加自定义功能。如果不符合标准,我想停止认证过程。我怎么做?如何在AuthenticationSuccessHandler中取消认证?
public function onAuthenticationSuccess(Request $request, TokenInterface $token) {
if(some_condition_applies){
//if success, resume default flow
return parent::onAuthenticationSuccess($request, $token);
}else{
//how to fail the authentication here?
}
}
在验证用户身份之后'onAuthenticationSuccess'被调用**。所以我认为你需要一个自定义的用户提供者。 –
我这么认为。在我查看了Symfony的默认身份验证提供程序之后,我意识到这是我必须进行更改的提供程序,而不是成功处理程序。 – Tholapz