src/Controller/SecurityController.php line 19

Open in your IDE?
  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. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/", name="app_home")
  13.      */
  14.     public function home(): Response
  15.     {
  16.         $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  17.         return $this->render('home.html.twig');
  18.     }
  19.     /**
  20.      * @Route("/login", name="app_login")
  21.      */
  22.     public function login(AuthenticationUtils $authenticationUtils): Response
  23.     {
  24.         // if ($this->getUser()) {
  25.         //     return $this->redirectToRoute('target_path');
  26.         // }
  27.         // get the login error if there is one
  28.         $error $authenticationUtils->getLastAuthenticationError();
  29.         // last username entered by the user
  30.         $lastUsername $authenticationUtils->getLastUsername();
  31.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  32.     }
  33.     /**
  34.      * @Route("/logout", name="app_logout")
  35.      */
  36.     public function logout(): void
  37.     {
  38.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  39.     }
  40. }