src/Controller/AuthController.php line 21

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 AuthController extends AbstractController
  8. {
  9.     #[Route('/auth'name'app_auth')]
  10.     public function index(): Response
  11.     {
  12.         return $this->render('auth/index.html.twig', [
  13.             'controller_name' => 'AuthController',
  14.         ]);
  15.     }
  16.      #[Route('/'name'app_sign_in')]
  17.      public function app_sign_in(AuthenticationUtils $authenticationUtils): Response
  18.      {
  19.          // get the login error if there is one
  20.          $error $authenticationUtils->getLastAuthenticationError();
  21.          // last username entered by the user
  22.          $lastUsername $authenticationUtils->getLastUsername();
  23.          return $this->render('auth/sign-in.html.twig', [
  24.              'last_username' => $lastUsername,
  25.              'error'         => $error,
  26.          ]);
  27.      }
  28.      #[Route('/sign-out'name'app_sign_out')]
  29.      public function app_sign_out(): Response
  30.      {
  31.              // controller can be blank: it will never be called!
  32.            throw new \Exception('Don\'t forget to activate logout in security.yaml');
  33.     }
  34. }