1 | <?php |
||
30 | class RegistrationController extends Controller |
||
31 | { |
||
32 | /** |
||
33 | * @Template |
||
34 | */ |
||
35 | public function displaySecondFactorTypesAction() |
||
36 | { |
||
37 | $institutionConfigurationOptions = $this->get('self_service.service.institution_configuration_options') |
||
|
|||
38 | ->getInstitutionConfigurationOptionsFor($this->getIdentity()->institution); |
||
39 | |||
40 | $identity = $this->getIdentity(); |
||
41 | |||
42 | /** @var SecondFactorService $service */ |
||
43 | $service = $this->get('surfnet_stepup_self_service_self_service.service.second_factor'); |
||
44 | |||
45 | // Get all available second factors from the config. |
||
46 | $allSecondFactors = $this->getParameter('ss.enabled_second_factors'); |
||
47 | |||
48 | $secondFactors = $service->getSecondFactorsForIdentity( |
||
49 | $identity, |
||
50 | $allSecondFactors, |
||
51 | $institutionConfigurationOptions->allowedSecondFactors, |
||
52 | $this->getParameter('self_service.second_factor.max_tokens_per_identity') |
||
53 | ); |
||
54 | |||
55 | if ($secondFactors->getRegistrationsLeft() <= 0) { |
||
56 | $this->get('logger')->notice( |
||
57 | 'User tried to register a new token but maximum number of tokens is reached. Redirecting to overview' |
||
58 | ); |
||
59 | return $this->forward('SurfnetStepupSelfServiceSelfServiceBundle:SecondFactor:list'); |
||
60 | } |
||
61 | |||
62 | |||
63 | $availableGsspSecondFactors = []; |
||
64 | foreach ($secondFactors->available as $index => $secondFactor) { |
||
65 | if ($this->has("gssp.view_config.{$secondFactor}")) { |
||
66 | /** @var ViewConfig $secondFactorConfig */ |
||
67 | $secondFactorConfig = $this->get("gssp.view_config.{$secondFactor}"); |
||
68 | $availableGsspSecondFactors[$index] = $secondFactorConfig; |
||
69 | // Remove the gssp second factors from the regular second factors. |
||
70 | unset($secondFactors->available[$index]); |
||
71 | } |
||
72 | } |
||
73 | return [ |
||
74 | 'commonName' => $this->getIdentity()->commonName, |
||
75 | 'availableSecondFactors' => $secondFactors->available, |
||
76 | 'availableGsspSecondFactors' => $availableGsspSecondFactors, |
||
77 | 'verifyEmail' => $this->emailVerificationIsRequired(), |
||
78 | ]; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @Template |
||
83 | */ |
||
84 | public function emailVerificationEmailSentAction() |
||
88 | |||
89 | /** |
||
90 | * @Template |
||
91 | * |
||
92 | * @param Request $request |
||
93 | * @return array|\Symfony\Component\HttpFoundation\RedirectResponse |
||
94 | */ |
||
95 | public function verifyEmailAction(Request $request) |
||
118 | |||
119 | /** |
||
120 | * @param $secondFactorId |
||
121 | * @return Response |
||
122 | */ |
||
123 | public function registrationEmailSentAction($secondFactorId) |
||
161 | |||
162 | /** |
||
163 | * @param $secondFactorId |
||
164 | * @return Response |
||
165 | * |
||
166 | * @SuppressWarnings(PHPMD.ExitExpression) MPDF requires bypassing Symfony, so we exit() when MPDF is done. |
||
167 | */ |
||
168 | public function registrationPdfAction($secondFactorId) |
||
183 | } |
||
184 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.