EntryPointController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 9
c 4
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A decideSecondFactorFlow() 0 13 3
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Copyright 2014 SURFnet bv
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
20
21
namespace Surfnet\StepupSelfService\SelfServiceBundle\Controller;
22
23
use Surfnet\StepupSelfService\SelfServiceBundle\Service\ActivationFlowService;
24
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SecondFactorService;
25
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SelfAssertedTokens\RecoveryTokenService;
26
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
27
use Symfony\Component\HttpFoundation\RedirectResponse;
28
use Symfony\Component\HttpFoundation\Request;
29
use Symfony\Component\Routing\Attribute\Route;
30
31
class EntryPointController extends AbstractController
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class EntryPointController
Loading history...
32
{
33
    public function __construct(
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
34
        private readonly SecondFactorService $secondFactorService,
35
        private readonly RecoveryTokenService $recoveryTokenService,
36
        private readonly ActivationFlowService $activationFlowService,
37
    ) {
38
    }
39
    #[Route(path: '/', name: 'ss_entry_point', methods:['GET'])]
40
    public function decideSecondFactorFlow(Request $request) : RedirectResponse
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function decideSecondFactorFlow()
Loading history...
41
    {
42
        $identity = $this->getUser()->getIdentity();
0 ignored issues
show
Bug introduced by
The method getIdentity() does not exist on Symfony\Component\Security\Core\User\UserInterface. It seems like you code against a sub-type of Symfony\Component\Security\Core\User\UserInterface such as Surfnet\StepupSelfServic...n\AuthenticatedIdentity. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        $identity = $this->getUser()->/** @scrutinizer ignore-call */ getIdentity();
Loading history...
43
        $hasSecondFactor = $this->secondFactorService->doSecondFactorsExistForIdentity($identity->id);
44
        $hasRecoveryToken = $this->recoveryTokenService->hasRecoveryToken($identity);
45
        // Check if we need to do a registration flow nudge
46
        // This is only used when already logged in
47
        $this->activationFlowService->processPreferenceFromUri($request->getUri());
48
49
        return $hasSecondFactor || $hasRecoveryToken
50
            ? $this->redirectToRoute('ss_second_factor_list')
51
            : $this->redirectToRoute('ss_registration_display_types');
52
    }
53
}
54