<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Contracts\Translation\TranslatorInterface;
class SecurityController extends AbstractController
{
#[Route(path: '/login', name: 'applicant_login')]
public function login(TranslatorInterface $translator, AuthenticationUtils $authenticationUtils): Response
{
if($this->getUser()) {
return $this->redirectToRoute('applicant-profile');
}
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
$message= $error?->getMessage();
if($message){
$message= $translator->trans($message);
}
return $this->render('security/applicant_login.html.twig', ['last_username' => $lastUsername, 'error' => $message]);
}
#[Route(path: '/logout', name: 'applicant_logout')]
public function logout(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
#[Route(path: '/login_check', name: 'login_check')]
public function check()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}