src/Controller/RoutingController.php line 22

Open in your IDE?
  1. <?php
  2. // src/Controller/RoutingController.php
  3. namespace App\Controller;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. use App\Utils\TokenDecoderUtils;
  8. use App\Entity\Buyer;
  9. class RoutingController extends AbstractController
  10. {
  11.     private $env "dev";
  12.     private $logger;
  13.     /**
  14.      * Entrance point of the application
  15.      * */
  16.     public function index($id null)
  17.     {
  18.         
  19.         return $this->render('index.html.twig', array(
  20.             "env" => $this->env,
  21.             "title" => "Findis",
  22.             "id" => $id,
  23.         ));
  24.     }
  25.     
  26.     /**
  27.      * Render login page
  28.      * @uses AuthenticationUtils
  29.      * @uses Request
  30.      * */
  31.     public function login(Request $requestAuthenticationUtils $authUtils)
  32.     {
  33.         $error $authUtils->getLastAuthenticationError();
  34.         // last username entered by the user
  35.         $lastUsername $authUtils->getLastUsername();
  36.         if(isset($error)) {
  37.             $error "Votre compte est peut être désactivé ou alors le login et le mot de passe que vous avez saisi sont incorrects.";
  38.         }
  39.         return $this->render('login.html.twig', array(
  40.             'last_username' => $lastUsername,
  41.             "title" => "Findis",
  42.             'error'         => $error,
  43.         ));
  44.     }
  45.     public function buyerPublic($token)
  46.     {
  47.         $decoder = new TokenDecoderUtils();
  48.         $value $decoder->decodeToken($token);
  49.         
  50.         if ($value == null) {
  51.             return $this->render('public/not_found.html.twig', array(
  52.                 "env" => $this->env,
  53.                 "title" => "Findis",
  54.                 "token" => $token,
  55.             ));
  56.         }
  57.         $buyer $this->getDoctrine()
  58.             ->getRepository(Buyer::class)
  59.             ->findByEmail($value);
  60.         if (!$buyer) {
  61.             return $this->render('public/not_found.html.twig', array(
  62.                 "env" => $this->env,
  63.                 "title" => "Findis",
  64.             ));
  65.         }
  66.         return $this->render('public/index.html.twig', array(
  67.             "env" => $this->env,
  68.             "title" => "Findis",
  69.             "token" => $token,
  70.         ));
  71.     }
  72. }