vendor/apidae-tourisme/apidae-bundle/src/Controller/SecurityController.php line 18

  1. <?php
  2. namespace ApidaeTourisme\ApidaeBundle\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
  7. use Symfony\Component\HttpFoundation\Session\Session;
  8. use Symfony\Component\HttpFoundation\RedirectResponse;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. #[Route('/apidaebundle'name'apidaebundle_')]
  12. class SecurityController extends AbstractController
  13. {
  14.     #[Route('/login'name'login')]
  15.     public function login(AuthenticationUtils $authenticationUtils): Response
  16.     {
  17.         // get the login error if there is one
  18.         $error $authenticationUtils->getLastAuthenticationError();
  19.         // last username entered by the user
  20.         $lastUsername $authenticationUtils->getLastUsername();
  21.         //return $this->redirectToRoute('connect_start', ['service' => 'apidae']) ;
  22.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  23.     }
  24.     #[Route('/logout'name'logout')]
  25.     public function logout()
  26.     {
  27.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  28.     }
  29.     /**
  30.      * Link to this controller to start the "connect" process
  31.      */
  32.     // #[Route('/connect/start', name: 'connect_start')]
  33.     // public function connectStart(Request $request, ClientRegistry $clientRegistry): RedirectResponse
  34.     // {
  35.     //     return match ($request->query->get('service')) {
  36.     //         'apidae' => $clientRegistry
  37.     //                     ->getClient($request->query->get('service'))
  38.     //                     ->redirect(['sso'], []),
  39.     //         'auth0' => $clientRegistry
  40.     //                     ->getClient($request->query->get('service'))
  41.     //                     ->redirect(['openid email'], []),
  42.     //         default => new RedirectResponse('index')
  43.     //     } ;
  44.     // }
  45.     /**
  46.      * Apidae redirects to back here afterwards
  47.      */
  48.     #[Route('/connect/check'name'connect_check')]
  49.     public function connectCheck(Session $session)
  50.     {
  51.         $target $session->get('_security.main.target_path');
  52.         if ($target != null) {
  53.             return $this->redirect($session->get('_security.main.target_path'));
  54.         } else {
  55.             return $this->redirectToRoute('index');
  56.         }
  57.     }
  58. }