在FOSUserBundle配置中,我有“success_handler”(使用Symfony 2.7)。 “onAuthenticationSuccess”是真的。但是,我想要getUser() “onAuthenticationSuccess”。我试图插入@ security.token_storage 在服务中,但令牌仍为空。你知不知道怎么? :)
答案 0 :(得分:0)
您也应该将它包含在构造函数中:
public function __construct(TokenStorageInterface $token_storage)
{
$this->token_storage = $token_storage;
}
然后使用类似的东西:
$iduser = $this->token_storage->getToken()->getUser()->getIduser();