<?php
// src/Controller/RoutingController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use App\Utils\TokenDecoderUtils;
use App\Entity\Buyer;
class RoutingController extends AbstractController
{
private $env = "dev";
private $logger;
/**
* Entrance point of the application
* */
public function index($id = null)
{
return $this->render('index.html.twig', array(
"env" => $this->env,
"title" => "Findis",
"id" => $id,
));
}
/**
* Render login page
* @uses AuthenticationUtils
* @uses Request
* */
public function login(Request $request, AuthenticationUtils $authUtils)
{
$error = $authUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authUtils->getLastUsername();
if(isset($error)) {
$error = "Votre compte est peut être désactivé ou alors le login et le mot de passe que vous avez saisi sont incorrects.";
}
return $this->render('login.html.twig', array(
'last_username' => $lastUsername,
"title" => "Findis",
'error' => $error,
));
}
public function buyerPublic($token)
{
$decoder = new TokenDecoderUtils();
$value = $decoder->decodeToken($token);
if ($value == null) {
return $this->render('public/not_found.html.twig', array(
"env" => $this->env,
"title" => "Findis",
"token" => $token,
));
}
$buyer = $this->getDoctrine()
->getRepository(Buyer::class)
->findByEmail($value);
if (!$buyer) {
return $this->render('public/not_found.html.twig', array(
"env" => $this->env,
"title" => "Findis",
));
}
return $this->render('public/index.html.twig', array(
"env" => $this->env,
"title" => "Findis",
"token" => $token,
));
}
}