我需要编写一个基本的身份验证处理程序。在我的onAuthenticationFailure
中,只是为了测试,我使用var转储$request
。使用糟糕的凭据应该可以工作,但什么也没发生。
我想我的srcAcmeTestBundleresourcesConfigservices.yml
:有问题
services:
authentication_handler:
class: AcmeTestBundleHandlerAuthenticationHandler
这是测试类,为了可读性删除了use语句:
namespace AcmeTestBundleHandler;
class AuthenticationHandler implements AuthenticationSuccessHandlerInterface,
AuthenticationFailureHandlerInterface, LogoutSuccessHandlerInterface
{
function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$user = $token->getUser();
}
function onAuthenticationFailure(Request $request,
AuthenticationException $exception)
{
var_dump($request);
die();
}
public function onLogoutSuccess(Request $request)
{
}
}
您需要在security.yml
文件中设置处理程序:
form_login:
success_handler: authentication_handler
failure_handler: authentication_handler
logout:
success_handler: authentication_handler