src/Controller/AppBundle/Controller/SecurityController.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Controller\AppBundle\Controller;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use App\Entity\Log;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/", name="login")
  13.      * @param AuthenticationUtils $authUtils
  14.      * @return \Symfony\Component\HttpFoundation\Response
  15.      */
  16.     public function loginAction(AuthenticationUtils $authUtilsRequest $requestEntityManagerInterface $em)
  17.     {
  18.         if ($this->isGranted('IS_AUTHENTICATED_FULLY')) {
  19.             return $this->redirectToRoute('dashboard');
  20.         }
  21.         $error $authUtils->getLastAuthenticationError();
  22.         $hasError = ($error != null);
  23.         $lastUser $authUtils->getLastUsername();
  24.         if ($hasError) {
  25.             Log::log($em$request'Login attempt'nullnull, [
  26.                 'email' => $lastUser
  27.             ]);
  28.         }
  29.         Log::log($em$request'Page load'null'Login');
  30.         return $this->render('@App/pages/security/login.html.twig', [
  31.             'hasError' => $hasError,
  32.             'lastUser' => $lastUser
  33.         ]);
  34.     }
  35. }