src/Sulu/Bundle/SecurityBundle/Controller/ResettingController.php
private function loginUser(UserInterface $user, $request)
    {
        $token = new UsernamePasswordToken($user, null, 'admin', $user->getRoles());
        $this->get('security.token_storage')->setToken($token); //now the user is logged in

        //now dispatch the login event
        $event = new InteractiveLoginEvent($request, $token);
        $this->get('event_dispatcher')->dispatch('security.interactive_login', $event);
    }
private function loginUser(UserInterface $user, $request)
    {
        $token = new UsernamePasswordToken($user, null, 'admin', $user->getRoles());
        $this->get('security.token_storage')->setToken($token); //now the user is logged in

        //now dispatch the login event
        $event = new InteractiveLoginEvent($request, $token);
        $this->get('event_dispatcher')->dispatch('security.interactive_login', $event);
    }
private function loginUser ( UserInterface $ user , $ request ) { $ token = new UsernamePasswordToken ( $ user , null , 'admin' , $ user -> getRoles ( ) ) ; $ this -> get ( 'security.token_storage' ) -> setToken ( $ token ) ; //now the user is logged in //now dispatch the login event $ event = new InteractiveLoginEvent ( $ request , $ token ) ; $ this -> get ( 'event_dispatcher' ) -> dispatch ( 'security.interactive_login' , $ event ) ; }
Gives a user a token, so she's logged in.

@param UserInterface $user
@param $request
Gives a user a token so she s logged in .