Code Duplication    Length = 18-19 lines in 4 locations

src/Surfnet/StepupRa/RaBundle/Controller/RaLocationController.php 2 locations

@@ 126-143 (lines=18) @@
123
124
        $form = $this->createForm(CreateRaLocationType::class, $command)->handleRequest($request);
125
126
        if ($form->isSubmitted() && $form->isValid()) {
127
            $logger->debug('RA Location form submitted, start processing command');
128
129
            $success = $this->getRaLocationService()->create($command);
130
131
            if ($success) {
132
                $this->addFlash(
133
                    'success',
134
                    $this->get('translator')->trans('ra.create_ra_location.created')
135
                );
136
137
                $logger->debug('RA Location added, redirecting to the RA location overview');
138
                return $this->redirectToRoute('ra_locations_manage', ['institution' => $command->institution]);
139
            }
140
141
            $logger->debug('RA Location creation failed, adding error to form');
142
            $this->addFlash('error', 'ra.create_ra_location.error.middleware_command_failed');
143
        }
144
145
        return $this->render('SurfnetStepupRaRaBundle:ra_location:create.html.twig', [
146
            'form' => $form->createView()
@@ 175-192 (lines=18) @@
172
173
        $form = $this->createForm(ChangeRaLocationType::class, $command)->handleRequest($request);
174
175
        if ($form->isSubmitted() && $form->isValid()) {
176
            $logger->debug('RA Location form submitted, start processing command');
177
178
            $success = $this->getRaLocationService()->change($command);
179
180
            if ($success) {
181
                $this->addFlash(
182
                    'success',
183
                    $this->get('translator')->trans('ra.create_ra_location.changed')
184
                );
185
186
                $logger->debug('RA Location added, redirecting to the RA location overview');
187
                return $this->redirectToRoute('ra_locations_manage', ['institution' => $command->institution]);
188
            }
189
190
            $logger->debug('RA Location creation failed, adding error to form');
191
            $this->addFlash('error', 'ra.create_ra_location.error.middleware_command_failed');
192
        }
193
194
        return $this->render('SurfnetStepupRaRaBundle:ra_location:change.html.twig', [
195
            'form' => $form->createView()

src/Surfnet/StepupRa/RaBundle/Controller/RaManagementController.php 1 location

@@ 190-207 (lines=18) @@
187
        $command->availableInstitutions = $selectOptions;
188
189
        $form = $this->createForm(CreateRaType::class, $command)->handleRequest($request);
190
        if ($form->isSubmitted() && $form->isValid()) {
191
            $logger->debug('Accreditation form submitted, start processing command');
192
193
            $success = $this->getRaCandidateService()->accreditCandidate($command);
194
195
            if ($success) {
196
                $this->addFlash(
197
                    'success',
198
                    $this->get('translator')->trans('ra.management.create_ra.identity_accredited')
199
                );
200
201
                $logger->debug('Identity Accredited, redirecting to candidate overview');
202
                return $this->redirectToRoute('ra_management_ra_candidate_search');
203
            }
204
205
            $logger->debug('Identity Accreditation failed, adding error to form');
206
            $this->addFlash('error', 'ra.management.create_ra.error.middleware_command_failed');
207
        }
208
209
        return $this->render('SurfnetStepupRaRaBundle:ra_management:create_ra.html.twig', [
210
            'raCandidate' => $raCandidate->raCandidate,

src/Surfnet/StepupRa/RaBundle/Controller/Vetting/YubikeyController.php 1 location

@@ 55-73 (lines=19) @@
52
        $command = new VerifyYubikeyPublicIdCommand();
53
        $form = $this->createForm(VerifyYubikeyPublicIdType::class, $command)->handleRequest($request);
54
55
        if ($form->isSubmitted() && $form->isValid()) {
56
            $result = $this->getVettingService()->verifyYubikeyPublicId($procedureId, $command);
57
58
            if ($result->didPublicIdMatch()) {
59
                $logger->notice('Yubikey Verified, redirecting to verify identity');
60
61
                return $this->redirectToRoute('ra_vetting_verify_identity', ['procedureId' => $procedureId]);
62
            }
63
64
            if ($result->wasOtpInvalid()) {
65
                $this->addFlash('error', 'ra.verify_yubikey_command.otp.otp_invalid');
66
            } elseif ($result->didOtpVerificationFail()) {
67
                $this->addFlash('error', 'ra.verify_yubikey_command.otp.verification_error');
68
            } else {
69
                $this->addFlash('error', 'ra.prove_yubikey_possession.different_yubikey_used');
70
            }
71
72
            $logger->notice('Yubikey could not be verified, added error to form');
73
        }
74
75
        $logger->notice('Rendering Yubikey Verification Form');
76
        // OTP field is rendered empty in the template.