我已经成功切换到用户_switch_user=thomas
。
但是,以下内容在应该返回 true 时总是返回 false:
$security = $this->get('security.context');
$impersonated = $security->isGranted('ROLE_PREVIOUS_ADMIN');
die(var_dump($impersonated)); // == false
为什么我不能在安全上下文中获得 ROLE_PREVIOUS_ADMIN?
编辑 我登录:
?_switch_user=john@doe.com
自从:
providers:
main:
entity:
property: email
我的参数是默认值:
switch_user: true
我正确切换,这不是问题。
问题是在我模拟之后,用户没有 ROLE_PREVIOUS_ADMIN