标签:
重置一个令牌后切换角色
$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);
标签:
原文地址:http://www.cnblogs.com/g825482785/p/checkrole.html