GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 9c825d...85357b )
by Dmitri
04:32 queued 15s
created

TokenController::refreshAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Controller;
6
7
use Damax\Bundle\ApiAuthBundle\Jwt\TokenBuilder;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10
use Symfony\Component\HttpFoundation\JsonResponse;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
13
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
14
use Symfony\Component\Security\Core\User\UserInterface;
15
16
class TokenController
17
{
18
    private $securityTokenStorage;
19
20
    public function __construct(TokenStorageInterface $securityTokenStorage)
21
    {
22
        $this->securityTokenStorage = $securityTokenStorage;
23
    }
24
25
    /**
26
     * @Method("GET")
27
     * @Route("/refresh-token")
28
     *
29
     * @throws UnauthorizedHttpException
30
     */
31
    public function refreshAction(TokenBuilder $tokenBuilder): Response
32
    {
33
        $user = $this->securityTokenStorage->getToken()->getUser();
34
35
        if (!$user instanceof UserInterface) {
36
            throw new UnauthorizedHttpException('Bearer');
37
        }
38
39
        return JsonResponse::create(['token' => $tokenBuilder->fromUser($user)]);
40
    }
41
}
42