Authentication 使用FOSUserBundle登录控制器
我正在进行一个项目,用户可以使用证书登录 因此,如果POST请求中有有效的证书,我希望将用户登录到控制器并重定向到主站点 我正在使用FOSUserBundle,但没有找到任何解释这是否可能或如何实现的方法Authentication 使用FOSUserBundle登录控制器,authentication,symfony-2.1,fosuserbundle,autologin,Authentication,Symfony 2.1,Fosuserbundle,Autologin,我正在进行一个项目,用户可以使用证书登录 因此,如果POST请求中有有效的证书,我希望将用户登录到控制器并重定向到主站点 我正在使用FOSUserBundle,但没有找到任何解释这是否可能或如何实现的方法 有没有人已经这样做了,或者知道怎么做?我终于找到了答案 $token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $pw, "main", array(
有没有人已经这样做了,或者知道怎么做?我终于找到了答案
$token = new \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken($user, $pw, "main", array("ROLE_USER"));
$this->get('security.context')->setToken($token);
$event = new \Symfony\Component\Security\Http\Event\InteractiveLoginEvent($this->getRequest(), $token);
$this->get('event_dispatcher')->dispatch('security.interactive_login', $event);
$user = $this->get('security.context')->getToken()->getUser();