Passed
Push — feature/symfony6-upgrade ( 54174f...166417 )
by Paul
06:29
created

EntryPointController::decideSecondFactorFlow()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 13
rs 9.9332
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
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...
18
19
namespace Surfnet\StepupSelfService\SelfServiceBundle\Controller;
20
21
use Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication\AuthenticatedSessionStateHandler;
22
use Surfnet\StepupSelfService\SelfServiceBundle\Service\ActivationFlowService;
23
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SecondFactorService;
24
use Surfnet\StepupSelfService\SelfServiceBundle\Service\SelfAssertedTokens\RecoveryTokenService;
25
use Symfony\Component\HttpFoundation\Request;
26
use Symfony\Component\HttpKernel\Attribute\AsController;
27
use Symfony\Component\Routing\Annotation\Route;
28
29
class EntryPointController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class EntryPointController
Loading history...
30
{
31
    public function __construct(
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
32
        private readonly SecondFactorService $secondFactorService,
33
        private readonly RecoveryTokenService $recoveryTokenService,
34
        private readonly ActivationFlowService $activationFlowService,
35
        private readonly AuthenticatedSessionStateHandler $authStateHandler
36
    ) {
37
    }
38
39
//ss_entry_point:
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
40
//path:     /
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
41
//methods:  [GET]
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
42
//defaults: { _controller: SurfnetStepupSelfServiceSelfServiceBundle:EntryPoint:decideSecondFactorFlow }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
43
44
#[Route(path: '/', name: 'ss_entry_point', methods:['GET'] )]
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 4 spaces, found 0
Loading history...
Coding Style introduced by
Expected 0 spaces before closing parenthesis; 1 found
Loading history...
45
public function decideSecondFactorFlow(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

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

45
public function decideSecondFactorFlow(/** @scrutinizer ignore-unused */ Request $request)

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

Loading history...
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 0
Loading history...
Coding Style introduced by
You must use "/**" style comments for a function comment
Loading history...
46
    {
0 ignored issues
show
Coding Style introduced by
Opening brace indented incorrectly; expected 0 spaces, found 4
Loading history...
47
        $identity = $this->getIdentity();
48
        $hasSecondFactor = $this->secondFactorService->doSecondFactorsExistForIdentity($identity->id);
49
        $hasRecoveryToken = $this->recoveryTokenService->hasRecoveryToken($identity);
50
        $this->activationFlowService->process($this->authStateHandler->getCurrentRequestUri());
51
52
        if ($hasSecondFactor || $hasRecoveryToken) {
53
            return $this->redirect($this->generateUrl('ss_second_factor_list'));
54
        } else {
55
            return $this->redirect(
56
                $this->generateUrl('ss_registration_display_types')
57
            );
58
        }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 8
Loading history...
59
    }
0 ignored issues
show
Coding Style introduced by
Closing brace indented incorrectly; expected 0 spaces, found 4
Loading history...
60
}
61