protected function authenticateUser(Request $request, UserInterface $user, $resourceOwnerName, $accessToken, $fakeLogin = true)
    {
        try {
            $this->container->get('hwi_oauth.user_checker')->checkPreAuth($user);
            $this->container->get('hwi_oauth.user_checker')->checkPostAuth($user);
        } catch (AccountStatusException $e) {
            // Don't authenticate locked, disabled or expired users
            return;
        }

        $token = new OAuthToken($accessToken, $user->getRoles());
        $token->setResourceOwnerName($resourceOwnerName);
        $token->setUser($user);
        $token->setAuthenticated(true);

        $this->get('security.token_storage')->setToken($token);

        if ($fakeLogin) {
            // Since we're "faking" normal login, we need to throw our INTERACTIVE_LOGIN event manually
            $this->container->get('event_dispatcher')->dispatch(
                SecurityEvents::INTERACTIVE_LOGIN,
                new InteractiveLoginEvent($request, $token)
            );
        }
    }
protected function authenticateUser(Request $request, UserInterface $user, $resourceOwnerName, $accessToken, $fakeLogin = true)
    {
        try {
            $this->container->get('hwi_oauth.user_checker')->checkPreAuth($user);
            $this->container->get('hwi_oauth.user_checker')->checkPostAuth($user);
        } catch (AccountStatusException $e) {
            // Don't authenticate locked, disabled or expired users
            return;
        }

        $token = new OAuthToken($accessToken, $user->getRoles());
        $token->setResourceOwnerName($resourceOwnerName);
        $token->setUser($user);
        $token->setAuthenticated(true);

        $this->get('security.token_storage')->setToken($token);

        if ($fakeLogin) {
            // Since we're "faking" normal login, we need to throw our INTERACTIVE_LOGIN event manually
            $this->container->get('event_dispatcher')->dispatch(
                SecurityEvents::INTERACTIVE_LOGIN,
                new InteractiveLoginEvent($request, $token)
            );
        }
    }
protected function authenticateUser ( Request $ request , UserInterface $ user , $ resourceOwnerName , $ accessToken , $ fakeLogin = true ) { try { $ this -> container -> get ( 'hwi_oauth.user_checker' ) -> checkPreAuth ( $ user ) ; $ this -> container -> get ( 'hwi_oauth.user_checker' ) -> checkPostAuth ( $ user ) ; } catch ( AccountStatusException $ e ) { // Don't authenticate locked, disabled or expired users return ; } $ token = new OAuthToken ( $ accessToken , $ user -> getRoles ( ) ) ; $ token -> setResourceOwnerName ( $ resourceOwnerName ) ; $ token -> setUser ( $ user ) ; $ token -> setAuthenticated ( true ) ; $ this -> get ( 'security.token_storage' ) -> setToken ( $ token ) ; if ( $ fakeLogin ) { // Since we're "faking" normal login, we need to throw our INTERACTIVE_LOGIN event manually $ this -> container -> get ( 'event_dispatcher' ) -> dispatch ( SecurityEvents :: INTERACTIVE_LOGIN , new InteractiveLoginEvent ( $ request , $ token ) ) ; } }
Authenticate a user with Symfony Security.

@param Request       $request
@param UserInterface $user
@param string        $resourceOwnerName
@param string        $accessToken
@param bool          $fakeLogin
Authenticate a user with Symfony Security .