src/Controller/SecurityController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Repository\UserRepository;
  5. use Doctrine\ORM\OptimisticLockException;
  6. use Doctrine\ORM\ORMException;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  12. class SecurityController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/connexion", name="app_login")
  16.      */
  17.     public function login(AuthenticationUtils $authenticationUtilsRequest $request): Response
  18.     {
  19.         // if ($this->getUser()) {
  20.         //     return $this->redirectToRoute('target_path');
  21.         // }
  22.         // get the login error if there is one
  23.         $error $authenticationUtils->getLastAuthenticationError();
  24.         // last username entered by the user
  25.         $lastUsername $authenticationUtils->getLastUsername();
  26.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  27.     }
  28.     /**
  29.      * @Route("/logout", name="app_logout")
  30.      */
  31.     public function logout(): void
  32.     {
  33.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  34.     }
  35. }