src/Controller/SecurityController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  7. use Symfony\Component\HttpFoundation\Session\Session;
  8. class SecurityController extends AbstractController
  9. {    
  10.     /**
  11.      * @Route("/", name="login")
  12.      */
  13.     public function login(AuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         $state bin2hex(random_bytes(16));
  16.         $baseUrl 'http://account.dev.netways.fr/authorize?response_type=code&client_id='.$_ENV["CLIENT_ID"].'&redirect_uri=https://client.netways.link/user&state='.$state;
  17.         return $this->render('security/login.html.twig', [
  18.             'client_id' => $_ENV["CLIENT_ID"],
  19.             'baseUrl' => $baseUrl,
  20.         ]);
  21.     }
  22.     /**
  23.      * @Route("/logout", name="logout")
  24.      */
  25.     public function logout()
  26.     {
  27.         $session = new Session();
  28.         $session->clear();
  29.         throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
  30.     }
  31. }