Lines
0.00%
0 / 10
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| GoogleController | 0.00% | 0 / 10 | 0.00% | 0 / 2 | 6 | 0.00% | 0 / 1 | |||
| connect | 0.00% | 0 / 9 | 0.00% | 0 / 1 | 2 | |||||
| connectCheck | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace App\Controller\Security; | |
| 4 | ||
| 5 | use KnpU\OAuth2ClientBundle\Client\ClientRegistry; | |
| 6 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
| 7 | use Symfony\Component\HttpFoundation\RedirectResponse; | |
| 8 | use Symfony\Component\Routing\Attribute\Route; | |
| 9 | ||
| 10 | class GoogleController extends AbstractController | |
| 11 | { | |
| 12 | /** | |
| 13 | * Link to this controller to start the "connect" process. | |
| 14 | */ | |
| 15 | #[Route(path: '/connect/google', name: 'connect_google_start', methods: ['GET'])] | |
| 16 | public function connect( | |
| 17 | ClientRegistry $clientRegistry | |
| 18 | ): RedirectResponse { | |
| 19 | return $clientRegistry | |
| 20 | ->getClient('google') | |
| 21 | ->redirect( | |
| 22 | [ | |
| 23 | 'profile', | |
| 24 | 'email', // the scopes you want to access | |
| 25 | ], | |
| 26 | [] | |
| 27 | ); | |
| 28 | } | |
| 29 | ||
| 30 | /** | |
| 31 | * After going to Google, you're redirected back here | |
| 32 | * because this is the "redirect_route" you configured | |
| 33 | * in config/packages/knpu_oauth2_client.yaml. | |
| 34 | */ | |
| 35 | #[Route(path: '/connect/google/check', name: 'connect_google_check', methods: ['GET'])] | |
| 36 | public function connectCheck(): RedirectResponse | |
| 37 | { | |
| 38 | return $this->redirectToRoute('app_default'); | |
| 39 | } | |
| 40 | } |