src/Controller/MontheatreConnexionController.php line 57

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\ClassTheatre\TheatreController;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. use Symfony\Contracts\Translation\TranslatorInterface;
  10. use TheatreCore\Entity\Extranetusers;
  11. class MontheatreConnexionController extends TheatreController
  12. {
  13.     // page de connexion
  14.     public $page_connexion '/montheatre/connexion';
  15.     // page de recup des codes
  16.     public $page_recuppass '/montheatre/recuppass';
  17.     // page de validation
  18.     public $validation_page '/montheatre/validation/';
  19.     // page de profil
  20.     public $login_page '/montheatre/';
  21.     public $params = array();
  22.     protected $authenticationUtils;
  23.     // {{{ _construct()
  24.     /** constructeur hérité
  25.      *
  26.      */
  27.     public function __construct(EntityManagerInterface $emTranslatorInterface $translatorTokenStorageInterface $tokenStorageAuthenticationUtils $authenticationUtils)
  28.     {
  29.         parent::__construct($translator$tokenStorage);
  30.         $this->context['controller'] = $this->view->controller 'montheatre';
  31.         $this->page_recuppass $_ENV['URL_THNET'] . $this->page_recuppass;
  32.         $this->em $em;
  33.         $this->authenticationUtils $authenticationUtils;
  34.     }
  35.     // }}}
  36.     // {{{ view()
  37.     /** Affichage
  38.      *
  39.      * @Route("/montheatre/connexion", name="app_login")
  40.      *
  41.      * @access public
  42.      */
  43.     public function action_connexion(Request $request$execute true$params = [])
  44.     {
  45.         //Si l'utilisateur est déjà connecté on le redirige
  46.         if ($this->getUser() instanceof Extranetusers) {
  47.             if (empty($params['ignore_redirect'])) {
  48.                 return $this->redirect('/montheatre/');
  49.             }
  50.             return true;
  51.         }
  52.         // get the login error if there is one
  53.         $error $request->getSession()->getFlashBag()->get('error');
  54.         $request->getSession()->getFlashBag()->clear();
  55.         // last username entered by the user
  56.         $lastUsername $this->authenticationUtils->getLastUsername();
  57.         $entete_connexion $this->getEnteteConnexion('entete_connexion');
  58.         if (!empty($entete_connexion)) {
  59.             $this->context['view']->entete_connexion $entete_connexion;
  60.         }
  61.         if (!empty($_REQUEST['special'])) {
  62.             $special urldecode($_REQUEST['special']);
  63.             $this->context['view']->{'special_' $special} = true;
  64.         }
  65.         $soustitre_connexion $this->getEnteteConnexion('soustitre_connexion');
  66.         if (!empty($soustitre_connexion)) {
  67.             $this->context['view']->soustitre_connexion $soustitre_connexion;
  68.         }
  69.         // si il y a un urifrom on l'ajoute en champ hidden
  70.         if (!empty($_REQUEST['urifrom'])) {
  71.             $urifrom urldecode($_REQUEST['urifrom']);
  72.             $this->context['view']->urifrom $urifrom;
  73.         } elseif (!empty($this->params['urifrom'])) {
  74.             $urifrom $this->params['urifrom'];
  75.             $this->context['view']->urifrom $urifrom;
  76.         } else {
  77.             $urifrom '';
  78.         }
  79.         $this->context['view']->page_recuppass $this->page_recuppass;
  80.         $this->context['view']->page_connexion $this->page_connexion;
  81.         $this->context['view']->last_username $lastUsername;
  82.         $this->context['view']->error $error;
  83.         if ($execute) {
  84.             return $this->view('montheatre/connexion.html.twig');
  85.         }
  86.         return null;
  87.     }
  88.     // }}}
  89.     /**
  90.      * @Route("/logout", name="app_logout")
  91.      */
  92.     public function logout()
  93.     {
  94.         throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  95.     }
  96.     function getEnteteConnexion($nom)
  97.     {
  98.         if (isset($_REQUEST[$nom]) && !empty($_REQUEST[$nom])) {
  99.             $$nom str_replace('_''/'$_REQUEST[$nom]);
  100.             if (file_exists($_ENV['PATH_APP'] . $GLOBALS['module'] . '/views/' . $$nom '/' $nom '.inc.html')) {
  101.                 return $$nom;
  102.             }
  103.         }
  104.     }
  105. }