src/Controller/SecurityController.php line 36

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. class SecurityController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/login", name="app_customer_login", host="%customers_domain%")
  11.      */
  12.     public function login_customer(AuthenticationUtils $authenticationUtils): Response
  13.     {
  14.         // if ($this->getUser()) {
  15.         //     return $this->redirectToRoute('target_path');
  16.         // }
  17.         if($this->isGranted('ROLE_USER')){
  18.             return $this->redirectToRoute('vehicle_index');
  19.         }
  20.         // get the login error if there is one
  21.         $error $authenticationUtils->getLastAuthenticationError();
  22.         // last username entered by the user
  23.         $lastUsername $authenticationUtils->getLastUsername();
  24.         return $this->render('security/login_customer.html.twig', ['last_username' => $lastUsername'error' => $error]);
  25.     }
  26.     /**
  27.      * @Route("/login", name="app_login")
  28.      */
  29.     public function login(AuthenticationUtils $authenticationUtils): Response
  30.     {
  31.         // if ($this->getUser()) {
  32.         //     return $this->redirectToRoute('target_path');
  33.         // }
  34.         if($this->isGranted('ROLE_USER')){
  35.             return $this->redirectToRoute('vehicle_index');
  36.         }
  37.         // get the login error if there is one
  38.         $error $authenticationUtils->getLastAuthenticationError();
  39.         // last username entered by the user
  40.         $lastUsername $authenticationUtils->getLastUsername();
  41.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  42.     }
  43.     /**
  44.      * @Route("/logout", name="app_logout")
  45.      */
  46.     public function logout()
  47.     {
  48.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  49.     }
  50. }