src/Controller/SecurityController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Service\Exceptions\LogoutException;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/login", name="login")
  13.      * @param Request $request
  14.      * @param AuthenticationUtils $authUtils
  15.      * @return Response
  16.      */
  17.     public function login(Request $requestAuthenticationUtils $authUtils)
  18.     {
  19.         $error $authUtils->getLastAuthenticationError();
  20.         $lastUsername $authUtils->getLastUsername();
  21.         if($error == NULL){
  22.           $error = array('messageKey' => '''messageData' => array());
  23.         }
  24.         return $this->render('security/login.html.twig', array(
  25.             'last_username' => $lastUsername,
  26.             'error' => $error,
  27.         ));
  28.     }
  29.     /**
  30.      * @Route("/logout", methods={"GET"})
  31.      * @throws LogoutException
  32.      */
  33.     public function logout()
  34.     {
  35.         throw new LogoutException('Don\'t forget to activate logout in security.yaml');
  36.     }
  37. }