src/Controller/SecurityController.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Informationeps;
  4. use App\Repository\InformationepsRepository;
  5. use App\Repository\UserRepository;
  6. use Doctrine\ORM\EntityManager;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  13. class SecurityController extends AbstractController
  14. {
  15.     /**
  16.      * @Route("/login", name="app_login")
  17.      */
  18.     public function login(AuthenticationUtils $authenticationUtils,InformationepsRepository $informationepsRepository,UserRepository $userRepositoryEntityManagerInterface $em): Response
  19.     {
  20.        
  21.         // if ($this->getUser()) {
  22.         //     return $this->redirectToRoute('target_path');
  23.         // }
  24.         // get the login error if there is one
  25.         $error $authenticationUtils->getLastAuthenticationError();
  26.         // last username entered by the user
  27.         $lastUsername $authenticationUtils->getLastUsername();
  28.         
  29.         $user $userRepository->findAll();
  30.         $nbrUser count($user);
  31.         if ($nbrUser == 0) {
  32.             return $this->redirectToRoute('app_onboarding_user', [], Response::HTTP_SEE_OTHER);
  33.         }
  34.         $logo $informationepsRepository->find(1);
  35.         if ($logo != null) {
  36.             $logo $logo->getImage();
  37.         }else
  38.         $logo "";
  39.         return $this->render('admin/security/login.html.twig', ['last_username' => $lastUsername'error' => $error,'logo'=>$logo]);
  40.     }
  41.     /**
  42.      * @Route("/logout", name="app_logout")
  43.      */
  44.     public function logout(): void
  45.     {
  46.         //return $this->ret;
  47.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  48.     }
  49. }