FosUserBundle模拟外部

时间:2019-03-27 14:00:24

标签: php symfony fosuserbundle impersonation

我正在尝试通过外部链接进行模拟。例如https://example.com/?_switch_user=email。因此,单击按钮时,它将重定向用户并立即模拟。很好问题是当我尝试模拟一个新用户时,导致500错误。如预期的那样,因为有一个模拟活动。我的问题是:是否可以先在后台运行https://example.com/?_switch_user=_exit,然后从外部重定向到新用户。

到目前为止,这是我的代码:

/**
 * @Route("/admin/client/{email}", name="client-impersonate")
 */
public function impersonate($email)
{
    // first run someting to exit the active impersonation and then redirect below

    return $this->redirect('https://example.com/?_switch_user='.$email);
}

我的备份解决方案是在example.com上创建某种侦听器,以首先检查是否存在主动模拟并首先“退出”。 但是我想知道我是否也可以使用上面的代码来做到这一点。 (重定向之前)

0 个答案:

没有答案
相关问题