When are user roles refreshed and how to force it?

后端 未结 8 1045
梦谈多话
梦谈多话 2020-12-14 02:57

First off, I\'m not using FOSUserBundle and I can\'t because I\'m porting a legacy system which has its own Model layer (no Doctrine/Mongo/whatsoever here) and other very cu

8条回答
  •  半阙折子戏
    2020-12-14 03:16

    From a Controller, after adding roles to a user, and saving to the database, simply call:

    // Force refresh of user roles
    $token = $this->get('security.context')->getToken()->setAuthenticated(false);
    

提交回复
热议问题