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