当覆盖 FOSUserBundle 重置密码控制器时,会调用“authenticateUser”方法(第 104 行):
....
$this->authenticateUser($user);
....
我的问题是我已经覆盖了 Symfony 身份验证处理程序,并且在用户登录时有我自己的逻辑。
编辑 这是我的身份验证处理程序:
<?php
/* ... all includes ... */
class AuthenticationHandler implements AuthenticationSuccessHandlerInterface, LogoutSuccessHandlerInterface
{
private $router;
private $container;
public function __construct(Router $router, ContainerInterface $container)
{
$this->router = $router;
$this->container = $container;
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
// retrieve user and session id
$user = $token->getUser();
/* ... here I do things in database when logging in, and dont want to write it again and again ... */
// prepare redirection URL
if($targetPath = $request->getSession()->get('_security.target_path')) {
$url = $targetPath;
}
else {
$url = $this->router->generate('my_route');
}
return new RedirectResponse($url);
}
}
那么,如何从 ResettingController 中的身份验证处理程序调用“onAuthenticationSuccess”方法?为了避免重写相同的代码...
谢谢你的帮助 !
奥雷尔