src/Controller/Admin/SecurityController.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Service\ActivityService;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. use Symfony\Component\Security\Http\Attribute\IsGranted;
  10. class SecurityController extends AbstractController
  11. {
  12.     private $entityManager;
  13.     private $activityService;
  14.     public function __construct(EntityManagerInterface $entityManager,ActivityService $activityService)
  15.     {
  16.         $this->entityManager $entityManager;
  17.         $this->activityService $activityService;
  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('index');
  26.         // get the login error if there is one
  27.         $error $authenticationUtils->getLastAuthenticationError();
  28.         // last username entered by the user
  29.         $lastUsername $authenticationUtils->getLastUsername();
  30.         $response $this->render('@admin/security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  31.         $response->headers->set('Cache-Control''no-store, no-cache, must-revalidate, max-age=0');
  32.         $response->headers->set('Pragma''no-cache');
  33.         $response->headers->set('Expires''0');
  34.         return $response;
  35.     }
  36.     /**
  37.      * @Route("/logout", name="app_logout")
  38.      */
  39.     public function logout()
  40.     {
  41.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  42.     }
  43. }