public function authenticateAction(Request $request)
    {
        if(!$this->getUser())
        {
            //Get redirecting route
            $referer = $request->headers->get('referer');
            //Get section on the page to be redirected at
            $pageSection = $request->get('section', false);

            $this->get('session')->set('refererUrl', $referer);

            if($pageSection)
            {
                $this->get('session')->set('refererUrlSection', $pageSection);
            }
        }

        $user = $this->get('security.token_storage')->getToken()->getUser();
        if (!is_object($user) || !$user instanceof UserInterface)
        {
            throw new AccessDeniedException('Please login first.');
        }

        $redirectURL = $this->get('session')->get('refererUrl', null);
        $redirectURLSection = $this->get('session')->get('refererUrlSection', null);

        if(!$redirectURL || $redirectURL == $this->generateUrl('ed_blog_redirect_authenticate', array(), true))
        {
            return $this->redirectToRoute("ed_blog_homepage_index");
        }
        else
        {
            if($redirectURLSection)
            {
                $redirectURL .= '#' . $redirectURLSection;
                $this->get('session')->remove('refererUrlSection');
            }

            $this->get('session')->remove('refererUrl');

            return $this->redirect($redirectURL) ;
        }

    }