src/Controller/Security/SecurityController.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\Security;
  4. use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  10. class SecurityController extends AbstractController
  11. {
  12.     /**
  13.      * @Route("/login", name="security_login")
  14.      */
  15.     public function login(AuthenticationUtils $authenticationUtils): Response
  16.     {
  17.         $error $authenticationUtils->getLastAuthenticationError();
  18.         $lastUsername $authenticationUtils->getLastUsername();
  19.         return $this->render('Security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  20.     }
  21.     /**
  22.      * @Route("/connect/social", name="security_social_login")
  23.      */
  24.     public function connect(ClientRegistry $clientRegistryRequest $request)
  25.     {
  26.         $client $clientRegistry->getClient($request->query->get('client'));
  27.         if ('facebook' === $request->query->get('client')) {
  28.             return $client->redirect(['public_profile''email'], []);
  29.         }
  30.         return $client->redirect(['email'], []);
  31.     }
  32.     /**
  33.      * @Route("/logout", name="security_logout")
  34.      */
  35.     public function logout(): void
  36.     {
  37.     }
  38. }