src/Controller/SecurityController.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. use Symfony\Contracts\Translation\TranslatorInterface;
  9. class SecurityController extends AbstractController
  10. {
  11.     #[Route(path'/login'name'applicant_login')]
  12.     public function login(TranslatorInterface $translatorAuthenticationUtils $authenticationUtils): Response
  13.     {
  14.         if($this->getUser()) {
  15.             return $this->redirectToRoute('applicant-profile');
  16.         }
  17.         $error $authenticationUtils->getLastAuthenticationError();
  18.         $lastUsername $authenticationUtils->getLastUsername();
  19.         $message$error?->getMessage();
  20.         if($message){
  21.             $message$translator->trans($message);
  22.         }
  23.         return $this->render('security/applicant_login.html.twig', ['last_username' => $lastUsername'error' => $message]);
  24.     }
  25.     #[Route(path'/logout'name'applicant_logout')]
  26.     public function logout(): void
  27.     {
  28.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  29.     }
  30.     #[Route(path'/login_check'name'login_check')]
  31.     public function check()
  32.     {
  33.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  34.     }
  35. }