src/Controller/AuthController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use LogicException;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class AuthController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/login", name="auth_login")
  12.      * @Template()
  13.      */
  14.     public function login(AuthenticationUtils $utils)
  15.     {
  16.         if ($this->getUser()) return $this->redirectToRoute('home_index');
  17.         $error $utils->getLastAuthenticationError();
  18.         $lastUsername $utils->getLastUsername();
  19.         return [
  20.             'error' => $error,
  21.             'last_username' => $lastUsername
  22.         ];
  23.     }
  24.     /**
  25.      * @Route("/logout", name="auth_logout")
  26.      */
  27.     public function logout(): array
  28.     {
  29.         throw new LogicException(
  30.             'This method can be blank - it will be intercepted by the logout key on your firewall.'
  31.         );
  32.     }
  33. }