2012-12-19 3 views
3

사용자가 인증서로 로그인 할 수있는 프로젝트에서 작업하고 있습니다.Log In in FOSUserBundle 컨트롤러

POST 요청에 유효한 인증서가있는 경우 컨트롤러에 사용자를 로그인하고 홈 사이트로 리디렉션하려고합니다.

FOSUserBundle을 사용하고 있지만 이것이 가능한지 또는 완료되었는지를 설명하는 내용을 찾지 못했습니다.

아무도 이미이 작업을 수행했거나 수행 방법을 알고 있었습니까?

답변

2

나는 결국 대답을 찾았습니다.

$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();