src/Controller/SecurityController.php line 25
<?phpnamespace App\Controller;use App\Entity\Log;use App\Entity\User;use Doctrine\ORM\EntityManagerInterface;use Doctrine\Persistence\ManagerRegistry;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 extends AbstractController{private EntityManagerInterface $em;public function __construct(EntityManagerInterface $em){$this->em = $em;}#[Route('/login', name: 'app_login')]public function login(AuthenticationUtils $authenticationUtils): Response{// if ($this->getUser()) {// return $this->redirectToRoute('target_path');// }// get the login error if there is one$error = $authenticationUtils->getLastAuthenticationError();// last username entered by the user$lastUsername = $authenticationUtils->getLastUsername();return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);}#[Route('/logout', name: 'app_logout')]public function logout(Request $request, ManagerRegistry $doctrine): void{// dd('here');// if ($this->getUser() != null) {// // Create log// $log = new Log();// $log->setCreatedBy($this->getUser());// $log->setLevel(1);// $log->setTitle("Déconnexion utilisateur");// $log->setDescription("L'utilisateur ".$this->getUser()->getUsername()." vient de se déconnecter : ".$this->getUser()->getUsername());// $log->setOthers("IP : ".$request->getClientIp()." Others : ".$request->headers->get('User-Agent'));// $em = $doctrine->getManager();// $em->persist($log);// $em->flush();// }// throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');}}