我的問題是捕獲用戶註銷。什麼我的代碼是:symfony2註銷
public function onAuthenticationFailure(Request $request, AuthenticationException $exception){
return new Response($this->translator->trans($exception->getMessage()));
}
public function logout(Request $request, Response $response, TokenInterface $token)
{
$empleado = $token->getUser();
$log = new Log();
$log->setFechalog(new \DateTime('now'));
$log->setTipo("Out");
$log->setEntidad("");
$log->setEmpleado($empleado);
$this->em->persist($log);
$this->em->flush();
}
public function onLogoutSuccess(Request $request) {
return new RedirectResponse($this->router->generate('login'));
}
問題是,當你正在運行的註銷功能無法訪問用戶令牌TokenInterface
?
的soluction問題是服務的安全上下文謝謝。 – paradita
'$ token-> getUser()'返回null嗎?或者'$ token'爲空? – Kosta