src/Controller/AuthController.php line 31

  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\UserRepository;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  9. class AuthController extends AbstractController
  10. {
  11.     /*#[Route('/login', name: 'app_login')]
  12.     public function login(AuthenticationUtils $authenticationUtils): Response
  13.     {
  14.         $error = $authenticationUtils->getLastAuthenticationError();
  15.         $lastUsername = $authenticationUtils->getLastUsername();
  16.         return $this->render('@EasyAdmin/page/login.html.twig', [
  17.             'last_username' => $lastUsername,
  18.             'error' => $error,
  19.             'csrf_token_intention' => 'authenticate',
  20.             'forgot_password_enabled' => true,
  21.         ]);
  22.     }*/
  23.     #[Route(path'/login'name'login')]
  24.     public function login(AuthenticationUtils $authenticationUtils): Response
  25.     {
  26.         if ($this->getUser()) {
  27.             return $this->redirectToRoute('dashboard.my_incentives');
  28.         }
  29.         // get the login error if there is one
  30.         $error $authenticationUtils->getLastAuthenticationError();
  31.         // last username entered by the user
  32.         $lastUsername $authenticationUtils->getLastUsername();
  33.         return $this->render('/security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  34.     }
  35. }