src/Controller/UserBundle/SecurityController.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\UserBundle;
  4. use App\Handler\JWTTokenHandler;
  5. use Psr\Log\LoggerInterface;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. class SecurityController extends AbstractController
  12. {
  13.     private JWTTokenHandler $JWTTokenHandler;
  14.     public function __construct(JWTTokenHandler  $JWTTokenHandlerLoggerInterface $logger)
  15.     {
  16.         $this->JWTTokenHandler $JWTTokenHandler;
  17.     }
  18.     public function login(AuthenticationUtils $authenticationUtilsRequest $request): Response
  19.     {
  20.         if ($this->getUser()) {
  21.             $user $this->getUser();
  22.             $this->JWTTokenHandler->handle($user);
  23.             return $this->redirectToRoute('localization');
  24.         }
  25.         $error $authenticationUtils->getLastAuthenticationError();
  26.         $lastUsername $authenticationUtils->getLastUsername();
  27.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  28.     }
  29.     /**
  30.      * @Route("/logout", name="app_logout")
  31.      */
  32.     public function logout()
  33.     {
  34.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  35.     }
  36. }