<?php
namespace App\Controller\Admin;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
* Class SecurityController.
*/
class SecurityController extends AbstractController
{
/**
* @return Response
*
* @Route("/empty", name="empty")
*/
public function empty(){
return new Response("");
}
/**
* @Route(
* "/login",
* name="admin_login",
* host="%host.monitoring%"
* )
*
* @param Request $request
* @param AuthenticationUtils $authUtils
*
* @return Response
*/
public function login(Request $request, AuthenticationUtils $authUtils): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('dashboard');
}
// get the login error if there is one
$error = $authUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authUtils->getLastUsername();
return $this->render('@EasyAdmin/page/login.html.twig', [
'csrf_token_intention' => 'authenticate',
'error' => $error,
'last_username' => $lastUsername,
]);
}
}