src/Controller/GoogleController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. class GoogleController extends Controller
  8. {
  9.     /**
  10.      * Link to this controller to start the "connect" process
  11.      *
  12.      * @Route("/connexion/google/", name="connect_google")
  13.      */
  14.     public function connectAction()
  15.     {
  16.         // will redirect to Google!
  17.         return $this->get('oauth2.registry')
  18.             ->getClient('google_main'// key used in config.yml
  19.             ->redirect();
  20.     }
  21.     /**
  22.      * After going to Google, you're redirected back here
  23.      * because this is the "redirect_route" you configured
  24.      * in config.yml
  25.      *
  26.      * @Route("/connexion/google/check", name="connect_google_check")
  27.      */
  28.     public function connectCheckAction(Request $request)
  29.     {
  30.         return $this->redirectToRoute("dashboard");
  31.     }
  32.     /**
  33.      * Link to this controller to start the "connect" process
  34.      *
  35.      * @Route("/connexion/echec", name="connect_fail")
  36.      */
  37.     public function failAction()
  38.     {
  39.         // will redirect to Google!
  40.         return $this->render('page/page-login.html.twig');
  41.     }
  42. }