How to get userid from eventlistener which are called from AJAX

后端 未结 3 1047
时光取名叫无心
时光取名叫无心 2021-01-12 05:23

I am using symfony2 and FOSUserBundle.

Normally,I can get user data from Controller

$user = $this->get(\'security.context\')->getToken()->g         


        
3条回答
  •  梦谈多话
    2021-01-12 06:26

    Be sure to not have the Symfony profiler/toolbar turned on. I don't know why, but that made $this->container->get('security.context')->getToken() return null every time.

    In the file, config_dev.yml make sure the following is set:

    web_profiler:
      toolbar: false
    

提交回复
热议问题