src/Controller/LoginController.php line 13

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. class LoginController extends AbstractController
  8. {
  9.     #[Route('/login'name'app_login')]
  10.     public function index(AuthenticationUtils $authenticationUtils): Response
  11.     {
  12.         $error $authenticationUtils->getLastAuthenticationError();
  13.         $lastUsername $authenticationUtils->getLastUsername();
  14.         if ($this->getUser()) {
  15.             return $this->redirectToRoute('app_panel_index');
  16.         }
  17.         return $this->render('login/index.html.twig', [
  18.             'error' => $error,
  19.             'last_username' => $lastUsername,
  20.         ]);
  21.     }
  22.     #[Route('/logout'name'app_logout'methods: ['GET'])]
  23.     public function logout()
  24.     {
  25.         // controller can be blank: it will never be called!
  26.         throw new \Exception('Don\'t forget to activate logout in security.yaml');
  27.     }
  28. }