src/Controller/SecurityController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. use App\Repository\user\AbonneRepository;
  8. use \Symfony\Component\HttpFoundation\Request;
  9. class SecurityController extends AbstractController
  10. {
  11.     public function __construct(AbonneRepository $abonneRepository )
  12.     {
  13.         $this->abonneRepository $abonneRepository;
  14.       
  15.     }
  16.     #[Route(path'{_locale}/login'name'app_login')]
  17.     public function login(Request $requestAuthenticationUtils $authenticationUtils): Response
  18.     {
  19.         // if ($this->getUser()) {
  20.         //     return $this->redirectToRoute('target_path');
  21.         // }
  22.         
  23.         // get the login error if there is one
  24.         $error $authenticationUtils->getLastAuthenticationError();
  25.         // last username entered by the user
  26.         $lastUsername $authenticationUtils->getLastUsername();
  27.         $adresseWeb $request->getHost();
  28.         
  29.         $objetAbonne =  $this->abonneRepository->findOneBy(['adresseWeb'=>$adresseWeb]);
  30.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername,'objetAbonne' => $objetAbonne'error' => $error]);
  31.     }
  32.     #[Route(path'{_locale}/logout'name'app_logout')]
  33.     public function logout(): void
  34.     {
  35.         
  36.         //throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  37.     }
  38. }