Newscoop\NewscoopBundle\Security\Http\Authentication\AuthenticationSuccessHandler::onAuthenticationSuccess PHP Method

onAuthenticationSuccess() public method

This is called when an interactive authentication attempt succeeds. This is called by authentication listeners inheriting from AbstractAuthenticationListener.
public onAuthenticationSuccess ( Request $request, Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token ) : Response
$request Symfony\Component\HttpFoundation\Request
$token Symfony\Component\Security\Core\Authentication\Token\TokenInterface
return Symfony\Component\HttpFoundation\Response The response to return
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        $user = $token->getUser();
        // This should actually be handle by the AuthenticationFailedHandler
        if (!$user->isAdmin()) {
            // can't go into admin
            $request->getSession()->set(SecurityContextInterface::AUTHENTICATION_ERROR, new AuthenticationException('User is not an admin.'));
            return $this->httpUtils->createRedirectResponse($request, 'admin_login');
        }
        \LoginAttempts::DeleteOldLoginAttempts();
        \LoginAttempts::ClearLoginAttemptsForIp();
        $zendAuth = \Zend_Auth::getInstance();
        $this->authAdapter->setUsername($user->getUsername())->setPassword($request->request->get('_password'))->setAdmin(true);
        $zendAuth->authenticate($this->authAdapter);
        $OAuthtoken = $this->userService->loginUser($user, 'oauth_authorize');
        $session = $request->getSession();
        $session->set('_security_oauth_authorize', serialize($OAuthtoken));
        $frontendToken = $this->userService->loginUser($user, 'frontend_area');
        $session = $request->getSession();
        $session->set('_security_frontend_area', serialize($frontendToken));
        \Article::UnlockByUser($user->getId());
        $request->setLocale($request->request->get('login_language'));
        $this->setNoCacheCookie($request);
        $user->setLastLogin(new \DateTime());
        $this->em->flush();
        if ($request->get('ajax') === 'true') {
            // close popup with login.
            return new Response("<script type=\"text/javascript\">window.parent.g_security_token = '" . \SecurityToken::GetToken() . "';window.parent.\$(window.parent.document.body).data('loginDialog').dialog('close');window.parent.setSecurityToken(window.parent.g_security_token);</script>");
        }
        return parent::onAuthenticationSuccess($request, $token);
    }
AuthenticationSuccessHandler