src/Hona/AuthBundle/Controller/HomeController.php line 17

Open in your IDE?
  1. <?php
  2. namespace Hona\AuthBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Hona\AuthBundle\Library\Utils;
  7. class HomeController extends Controller
  8. {
  9.     /**
  10.      * @Route("/", name="home")
  11.      * @param $request
  12.      */
  13.     public function indexAction(Request $request)
  14.     {
  15.         if(empty($request->get('redirect_uri'))){
  16.             $admin_domain = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' "https" "http") . "://".$this->getParameter('admin_domain');
  17.             $request->request->set('redirect_uri'$admin_domain);
  18.         }
  19.         if($this->get('session')->has('user_id')){
  20.             $parseUrl parse_url($request->get('redirect_uri'));
  21.             if(strpos($parseUrl["host"], $this->container->getParameter('parent_domain')) !== false){
  22.                 $accessToken Utils::createAccessToken($this->getDoctrine(), $this->get('session')->get('user_id'));
  23.                 setcookie("presence"Utils::doubleEncrypt($accessToken->getToken()), time() + Utils::getParameter("token_expires_in"), "/"".".$this->container->getParameter('parent_domain'));
  24.             }
  25.             return $this->redirect($request->get('redirect_uri'));
  26.         }else{
  27.             return $this->render('@HonaAuth/login.html.twig', array(
  28.                 "onlyMetas" => true,
  29.                 "redirect_uri" => $request->get('redirect_uri')
  30.             ));
  31.         }
  32.     }
  33. }