码迷,mamicode.com
首页 > 其他好文 > 详细

FOSUserBundle (用户切换角色)

时间:2016-06-06 13:38:25      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

重置一个令牌后切换角色

 

$loggedInUser = $this->get(‘security.context‘)->getToken()->getUser();
$loggedInUser->removeRole(‘ROLE_ABC‘);
$loggedInUser->addRole(‘ROLE_XYZ‘);

$token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken(
  $loggedInUser,
  null,
  ‘main‘,
  $loggedInUser->getRoles()
);

$this->container->get(‘security.context‘)->setToken($token);

 

FOSUserBundle (用户切换角色)

标签:

原文地址:http://www.cnblogs.com/g825482785/p/checkrole.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!