src/Controller/Auth/SecurityController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Auth;
  3. use MINK1367\ClientOauth\ManagerClientOauth;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/login", name="app.login")
  13.      */
  14.     public function login(AuthenticationUtils $authenticationUtils): Response
  15.     {
  16.         // if ($this->getUser()) {
  17.         //     return $this->redirectToRoute('target_path');
  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/security/login.html.twig', [
  24.             'last_username' => $lastUsername'error' => $error
  25.         ]);
  26.     }
  27.     /**
  28.      * @Route("/logout", name="app.logout")
  29.      */
  30.     public function logout()
  31.     {
  32.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  33.     }
  34.     /**
  35.      * @Route("/auth/callback", name="oauth_callback")
  36.      */
  37.     public function callback(Request $requestManagerClientOauth  $client) : Response
  38.     {
  39.         return $client->callback($request);
  40.     }
  41.     /**
  42.      * @Route("/auth/redirect", name="oauth_redirect")
  43.      */
  44.     public function oauthRedirect(Request $request,  ManagerClientOauth  $client) : Response
  45.     {
  46.         return $client->redirect($request);
  47.     }
  48. }