Completed
Push — master ( 65f314...a56b5d )
by Paweł
08:26
created

ExternalOauthController::connectCheckAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SWP\Bundle\CoreBundle\Controller;
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
class ExternalOauthController extends Controller
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...e\Controller\Controller has been deprecated with message: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
13
{
14
    /**
15
     * @Route("/connect/oauth", name="connect_oauth_start")
16
     */
17
    public function connectAction(Request $request): Response
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19
        $clientRegistry = $this->get('knpu.oauth2.registry');
20
21
        return $clientRegistry
22
            ->getClient('external_oauth')
23
            ->redirect([
24
                'openid', 'email', 'profile',
25
            ]);
26
    }
27
28
    /**
29
     * This is where the user is redirected after being succesfully authenticated by the OAuth server.
30
     *
31
     * @Route("/connect/oauth/check", name="connect_oauth_check")
32
     */
33
    public function connectCheckAction(Request $request): Response
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        // If we didn't log in, something went wrong. Throw an exception!
36
        if (!$this->getUser()) {
37
            $response = $this->render('bundles/TwigBundle/Exception/error403.html.twig');
38
            $response->setStatusCode(403);
39
40
            return $response;
41
        }
42
43
        return $this->redirectToRoute('homepage');
44
    }
45
}
46