public function logUser(\Symfony\Component\Security\Core\User\UserInterface $user)
    {
        // Here, "main" is the name of the firewall in your security.yaml
        $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
        $this->get('security.token_storage')->setToken($token);

        // Fire the login event
        $this->get('event_dispatcher')->dispatch(AuthenticationEvents::AUTHENTICATION_SUCCESS, new AuthenticationEvent($token));
    }
public function logUser(\Symfony\Component\Security\Core\User\UserInterface $user)
    {
        // Here, "main" is the name of the firewall in your security.yaml
        $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
        $this->get('security.token_storage')->setToken($token);

        // Fire the login event
        $this->get('event_dispatcher')->dispatch(AuthenticationEvents::AUTHENTICATION_SUCCESS, new AuthenticationEvent($token));
    }
public function logUser ( \ Symfony \ Component \ Security \ Core \ User \ UserInterface $ user ) { // Here, "main" is the name of the firewall in your security.yaml $ token = new UsernamePasswordToken ( $ user , null , 'main' , $ user -> getRoles ( ) ) ; $ this -> get ( 'security.token_storage' ) -> setToken ( $ token ) ; // Fire the login event $ this -> get ( 'event_dispatcher' ) -> dispatch ( AuthenticationEvents :: AUTHENTICATION_SUCCESS , new AuthenticationEvent ( $ token ) ) ; }
Log user correctly.

@param \Symfony\Component\Security\Core\User\UserInterface $user
Log user correctly .