vendor/friendsofsymfony/user-bundle/Controller/SecurityController.php line 52

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSUserBundle package.
  4.  *
  5.  * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace FOS\UserBundle\Controller;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  14. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  15. use App\Entity\RegistroUsuarios;
  16. /**
  17.  * Controller managing security.
  18.  *
  19.  * @author Thibault Duplessis <thibault.duplessis@gmail.com>
  20.  * @author Christophe Coevoet <stof@notk.org>
  21.  *
  22.  * @final
  23.  */
  24. class SecurityController extends AbstractController
  25. {
  26.     private $authenticationUtils;
  27.     private $tokenManager;
  28.     public function __construct(AuthenticationUtils $authenticationUtilsCsrfTokenManagerInterface $tokenManager null)
  29.     {
  30.         $this->authenticationUtils $authenticationUtils;
  31.         $this->tokenManager $tokenManager;
  32.     }
  33.     public function loginAction(): Response
  34.     {
  35.         
  36.         $error $this->authenticationUtils->getLastAuthenticationError();
  37.         $lastUsername $this->authenticationUtils->getLastUsername();
  38.         $csrfToken $this->tokenManager
  39.             $this->tokenManager->getToken('authenticate')->getValue()
  40.             : null;
  41.         return $this->renderLogin([
  42.             'last_username' => $lastUsername,
  43.             'error' => $error,
  44.             'csrf_token' => $csrfToken,
  45.         ]);
  46.     }
  47.     public function checkAction()
  48.     {
  49.         throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
  50.     }
  51.     public function logoutAction()
  52.     {
  53.         throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
  54.     }
  55.     /**
  56.      * Renders the login template with the given parameters. Overwrite this function in
  57.      * an extended controller to provide additional data for the login template.
  58.      */
  59.     protected function renderLogin(array $data): Response
  60.     {
  61.         return $this->render('@FOSUser/Security/login.html.twig'$data);
  62.     }
  63. }