<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class GoogleController extends Controller
{
/**
* Link to this controller to start the "connect" process
*
* @Route("/connexion/google/", name="connect_google")
*/
public function connectAction()
{
// will redirect to Google!
return $this->get('oauth2.registry')
->getClient('google_main') // key used in config.yml
->redirect();
}
/**
* After going to Google, you're redirected back here
* because this is the "redirect_route" you configured
* in config.yml
*
* @Route("/connexion/google/check", name="connect_google_check")
*/
public function connectCheckAction(Request $request)
{
return $this->redirectToRoute("dashboard");
}
/**
* Link to this controller to start the "connect" process
*
* @Route("/connexion/echec", name="connect_fail")
*/
public function failAction()
{
// will redirect to Google!
return $this->render('page/page-login.html.twig');
}
}