src/Controller/LoginController.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\JsonResponse;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class LoginController extends AbstractController
  9. {
  10.     #[Route('/healthcheck'name'healthcheck'methods: ['GET'])]
  11.     public function base(): JsonResponse
  12.     {
  13.         return $this->json((new \DateTime())->format('Y-m-d H:i:s'));
  14.     }
  15.     #[Route(path'/login'name'app_login')]
  16.     public function login(AuthenticationUtils $authenticationUtils): Response
  17.     {
  18.         if ($this->getUser()) {
  19.             return $this->redirectToRoute('/audit');
  20.         }
  21.         // get the login error if there is one
  22.         $error $authenticationUtils->getLastAuthenticationError();
  23.         // last username entered by the user
  24.         $lastUsername $authenticationUtils->getLastUsername();
  25.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  26.     }
  27.     #[Route(path'/logout'name'app_logout')]
  28.     public function logout(): void
  29.     {
  30.     }
  31. }