src/Controller/SecurityController.php line 23

  1. <?php
  2. namespace App\Controller;
  3. use LogicException;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. /**
  9.  * Class SecurityController
  10.  */
  11. class SecurityController extends AbstractController
  12. {
  13.     /**
  14.      * @Route("/login", name="app_login")
  15.      *
  16.      * @param AuthenticationUtils $authenticationUtils
  17.      *
  18.      * @return Response
  19.      */
  20.     public function login(AuthenticationUtils $authenticationUtils): Response
  21.     {
  22.         if ($this->getUser()) {
  23.             return $this->redirectToRoute('shop.dashboard');
  24.         }
  25.         return $this->render('security/login.html.twig', [
  26.             'lastUsername' => $authenticationUtils->getLastUsername(),
  27.             'error'        => $authenticationUtils->getLastAuthenticationError()
  28.         ]);
  29.     }
  30.     /**
  31.      * @Route("/logout", name="app_logout")
  32.      */
  33.     public function logout()
  34.     {
  35.         throw new LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  36.     }
  37. }