src/Controller/Website/Auth/LoginController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Website\Auth;
  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 Symfony\Component\HttpFoundation\RedirectResponse;
  8. use Symfony\Component\HttpFoundation\RequestStack;
  9. class LoginController extends AbstractController
  10. {
  11.     private $requestStack;
  12.     public function __construct(RequestStack $requestStack)
  13.     {
  14.         $this->requestStack $requestStack;
  15.     }
  16.     /**
  17.      * @Route("/{_locale}/login", name="login")
  18.      */
  19.     public function login(AuthenticationUtils $authenticationUtils): Response
  20.     {
  21.         if ($this->getUser()) {
  22.             $request $this->requestStack->getCurrentRequest();
  23.             $locale $request->getLocale();
  24.             return new RedirectResponse('/' $locale '/mediabank');
  25.         }
  26.         // get the login error if there is one
  27.         $error $authenticationUtils->getLastAuthenticationError();
  28.         // last username entered by the user
  29.         $lastUsername $authenticationUtils->getLastUsername();
  30.         //  $lastUsername = "";
  31.         $errorMessage "";
  32.         if ($error) {
  33.             $errorMessage "You have entered an incorrect email or password. If you happen to forget it, please contact us at infо@modern.expo";
  34.         }
  35.         return $this->render('auth/login.html.twig', ['last_username' => $lastUsername'error' => $errorMessage]);
  36.         //return $this->render('auth/login.html.twig', []);
  37.     }
  38.     /**
  39.      * @Route("/logout", name="logout")
  40.      */
  41.     public function logout(): void
  42.     {
  43.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  44.     }
  45. }