簡體   English   中英

Symfony中“ onAuthenticationSuccess”中的getUser()

[英]getUser() in “onAuthenticationSuccess” with Symfony

在FOSUserBundle配置中,我有“ success_handler”(使用Symfony 2.7)。 “ onAuthenticationSuccess”為true。 但是,我想在“ onAuthenticationSuccess”中使用getUser()。 我試圖在服務中插入@ security.token_storage,但是令牌仍然為空。 你知不知道怎么? :)

您還應該將其包括在構造函數中:

public function __construct(TokenStorageInterface $token_storage)
{
    $this->token_storage = $token_storage;
}

然后使用類似:

$iduser = $this->token_storage->getToken()->getUser()->getIduser();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM