src/Controller/Admin/SecurityController.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  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.      * @return Response
  15.      *
  16.      * @Route("/empty", name="empty")
  17.      */
  18.     public function empty(){
  19.         return new Response("");
  20.     }
  21.     /**
  22.      * @Route(
  23.      *     "/login",
  24.      *     name="admin_login",
  25.      *     host="%host.monitoring%"
  26.      * )
  27.      *
  28.      * @param Request             $request
  29.      * @param AuthenticationUtils $authUtils
  30.      *
  31.      * @return Response
  32.      */
  33.     public function login(Request $requestAuthenticationUtils $authUtils): Response
  34.     {
  35.         if ($this->getUser()) {
  36.             return $this->redirectToRoute('dashboard');
  37.         }
  38.         // get the login error if there is one
  39.         $error $authUtils->getLastAuthenticationError();
  40.         // last username entered by the user
  41.         $lastUsername $authUtils->getLastUsername();
  42.         return $this->render('@EasyAdmin/page/login.html.twig', [
  43.             'csrf_token_intention' => 'authenticate',
  44.             'error' => $error,
  45.             'last_username' => $lastUsername,
  46.         ]);
  47.     }
  48. }