<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
* @Route("/{_locale}", requirements={"_locale": "ar|fr"})
*/
class SecurityController extends AbstractController
{
#[Route(path: '/', name: 'locale_login')]
public function localeLog(AuthenticationUtils $authenticationUtils): Response
{
return $this->redirectToRoute('login');
}
#[Route(path: '/login', name: 'login')]
public function loginUser(AuthenticationUtils $authenticationUtils): Response
{
// if ($this->getUser()) {
// return $this->redirectToRoute('target_path');
// }
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login_global.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
#[Route(path: '/logout', name: 'logout')]
public function logoutUser(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route(path: '/admin/login', name: 'admin_login')]
public function loginAdmin(AuthenticationUtils $authenticationUtils): Response
{
// if ($this->getUser()) {
// return $this->redirectToRoute('target_path');
// }
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
#[Route(path: '/admin/logout', name: 'admin_logout')]
public function logoutAdmin(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route(path: '/inseminateur/login', name: 'inseminateur_login')]
public function loginInseminateur(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login_inseminateur.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
#[Route(path: '/inseminateur/logout', name: 'inseminateur_logout')]
public function logoutInseminateur(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route(path: '/agentOEP/login', name: 'agent_oep_login')]
public function loginAgentOEP(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login_agent_oep.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
#[Route(path: '/agentOEP/logout', name: 'agent_oep_logout')]
public function logoutAgentOEP(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route(path: '/agent/login', name: 'agent_login')]
public function loginAgent(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login_agent.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
#[Route(path: '/agent/logout', name: 'agent_logout')]
public function logoutAgent(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route(path: '/eleveur/login', name: 'eleveur_login')]
public function loginEleveur(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('security/login_eleveur.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
}
#[Route(path: '/eleveur/logout', name: 'eleveur_logout')]
public function logoutEleveur(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}