src/Controller/SecurityController.php line 25

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 SecurityController extends AbstractController
  8. {
  9.     /**
  10.      * @Route("/logout", name="app_logout")
  11.      */
  12.     public function logout()
  13.     {
  14.         throw new \Exception('Will be intercepted before getting here');
  15.     }
  16.     /**
  17.      * @Route("/sign-in", name="app_sign_in")
  18.      * @param AuthenticationUtils $authenticationUtils
  19.      * @return Response
  20.      */
  21.     public function signIn(AuthenticationUtils $authenticationUtils): Response
  22.     {
  23.         if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED', $this->getUser())) {
  24.             return $this->redirectToRoute('dashboard');
  25.         }
  26.         $error = $authenticationUtils->getLastAuthenticationError();
  27.         $lastUsername = $authenticationUtils->getLastUsername();
  28.         return $this->render('security/sign-in.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
  29.     }
  30. }