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
|
|
|
*/ |
|
|
|
|
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 |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
public function __construct( |
|
|
|
|
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 |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
$identity = $this->getUser()->getIdentity(); |
|
|
|
|
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
|
|
|
|