src/Controller/SecurityController.php line 51

  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 App\Controller;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
  16. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  17. class SecurityController extends AbstractController
  18. {
  19.     private $authenticationUtils;
  20.     private $tokenManager;
  21.     /**
  22.      * SecurityController constructor.
  23.      * @param AuthenticationUtils $authenticationUtils
  24.      * @param CsrfTokenManagerInterface|null $tokenManager
  25.      */
  26.     public function __construct(AuthenticationUtils $authenticationUtilsCsrfTokenManagerInterface $tokenManager null)
  27.     {
  28.         $this->authenticationUtils $authenticationUtils;
  29.         $this->tokenManager $tokenManager;
  30.     }
  31.     /**
  32.      * @Route("/login", name="home_login")
  33.      */
  34.     public function loginAction(Request $request$fbLoginUrl ""$googleLoginUrl ''): Response
  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->render('clienti/login_primary.html.twig', array(
  42.             'last_username' => $lastUsername,
  43.             'error' => $error,
  44.             'csrf_token' => $csrfToken,
  45.             'fb_login_url' => $fbLoginUrl,
  46.             'google_login_url' => $googleLoginUrl
  47.         ));
  48.     }
  49.     public function checkAction()
  50.     {
  51.         throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
  52.     }
  53.     public function logoutAction()
  54.     {
  55.         throw new \RuntimeException('You must activate the logout in your security firewall configuration.');
  56.     }
  57. }