【发布时间】:2020-11-06 04:53:21
【问题描述】:
我尝试使用 easyAdmin3 快速创建管理员帐户,但是如何进行正确的模拟用户操作?
我已经尝试了很多东西,但最好的选择是自定义操作,所以这个链接出现在页面中,但它不能正常工作......
模拟有效,但仅在 url 中链接的页面上(如果页面更改,模拟已停止)并且用户在 Symfony 工具栏中没有更改...
我的自定义操作:
public function configureActions(Actions $actions): Actions
{
$impersonate = Action::new('impersonate', 'Impersonate')
->linkToRoute('web_account_index', function (User $entity) {
return [
'id' => $entity->getId(),
'?_switch_user' => $entity->getEmail()
];
})
;
return parent::configureActions($actions)
->add(Crud::PAGE_INDEX, Action::DETAIL)
->add(Crud::PAGE_INDEX, $impersonate)
;
}
结果: Dashboard link for each user
点击模拟后,我有这个网址:
https://blog-community.wip/account/7?eaContext=37a8719&?_switch_user=user7@user.com
内容正常(用户 7 的页面帐户),但 Symfony Profiler 显示用户管理员而不是模拟用户:
更改页面退出模拟...
Real Symfony impersonate 即使页面更改也会保持模拟,因为登录的分析器用户不同Symfony profiler user logged with impersonate directly in url
文档没有提到这个功能,EasyAdmin 的 Github 也和这个网站一样。
感谢您的帮助
【问题讨论】:
标签: php symfony4 impersonation easyadmin