src/Controller/App/LoginController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller\App;
  3. use App\Security\UserChecker;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\ErrorHandler\Debug;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  10. use Symfony\Component\Security\Core\Security;
  11. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  12. class LoginController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/login", name="login")
  16.      */
  17.     public function index(AuthenticationUtils $authenticationUtils): Response
  18.     {
  19.         // get the login error if there is one
  20.         $error $authenticationUtils->getLastAuthenticationError();
  21.         // last username entered by the user
  22.         $lastUsername $authenticationUtils->getLastUsername();
  23.         return $this->render('app/login/index.html.twig',
  24.             [
  25.                 'last_username' => $lastUsername,
  26.                 'error'         => $error,
  27.             ]
  28.         );
  29.       }
  30.     /**
  31.      * @Route("/logout", name="logout", methods={"GET"})
  32.      */
  33.     public function logout(): void
  34.     {
  35.         // controller can be blank: it will never be called!
  36.         throw new \Exception('Don\'t forget to activate logout in security.yaml');
  37.     }
  38.     /**
  39.      * @Route("/log-out", name="app_logout", methods={"GET"})
  40.      */
  41.     public function logoutApp(){
  42.         return $this->render('app/login/logout.html.twig');
  43.     }
  44. }