src/Controller/SecurityController.php line 17

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