Code Duplication    Length = 35-35 lines in 2 locations

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

@@ 203-237 (lines=35) @@
200
     * @param Request $request
201
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
202
     */
203
    public function removeAction(Request $request)
204
    {
205
        $this->denyAccessUnlessGranted(['ROLE_RA']);
206
207
        $logger = $this->get('logger');
208
209
        $logger->notice('Received request to remove RA location');
210
211
        $command = new RemoveRaLocationCommand();
212
        $command->currentUserId = $this->getCurrentUser()->id;
213
214
        $form = $this->createForm(RemoveRaLocationType::class, $command);
215
        $form->handleRequest($request);
216
217
        $logger->info(sprintf(
218
            'Sending middleware request to remove RA location "%s" belonging to "%s" on behalf of "%s"',
219
            $command->locationId,
220
            $command->institution,
221
            $command->currentUserId
222
        ));
223
224
        $translator = $this->get('translator');
225
        $flashBag = $this->get('session')->getFlashBag();
226
        if ($this->getRaLocationService()->remove($command)) {
227
            $logger->notice('RA Location removal Succeeded');
228
            $flashBag->add('success', $translator->trans('ra.ra_location.revocation.removed'));
229
        } else {
230
            $logger->notice('RA Location removal Failed');
231
            $flashBag->add('error', $translator->trans('ra.ra_location.revocation.could_not_remove'));
232
        }
233
234
        $logger->notice('Redirecting back to RA Location Manage Page');
235
236
        return $this->redirectToRoute('ra_locations_manage', ['institution' => $command->institution]);
237
    }
238
239
    /**
240
     * @return \Surfnet\StepupRa\RaBundle\Service\RaLocationService

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

@@ 118-152 (lines=35) @@
115
     * @param Request $request
116
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
117
     */
118
    public function revokeAction(Request $request)
119
    {
120
        $this->denyAccessUnlessGranted(['ROLE_RA']);
121
122
        $logger = $this->get('logger');
123
124
        $logger->notice('Received request to revoke Second Factor');
125
126
        $command = new RevokeSecondFactorCommand();
127
        $command->currentUserId = $this->getCurrentUser()->id;
128
129
        $form = $this->createForm(RevokeSecondFactorType::class, $command);
130
        $form->handleRequest($request);
131
132
        $logger->info(sprintf(
133
            'Sending middleware request to revoke Second Factor "%s" belonging to "%s" on behalf of "%s"',
134
            $command->secondFactorId,
135
            $command->identityId,
136
            $command->currentUserId
137
        ));
138
139
        $translator = $this->get('translator');
140
        $flashBag = $this->get('session')->getFlashBag();
141
        if ($this->getSecondFactorService()->revoke($command)) {
142
            $logger->notice('Second Factor revocation Succeeded');
143
            $flashBag->add('success', $translator->trans('ra.second_factor.revocation.revoked'));
144
        } else {
145
            $logger->notice('Second Factor revocation Failed');
146
            $flashBag->add('error', $translator->trans('ra.second_factor.revocation.could_not_revoke'));
147
        }
148
149
        $logger->notice('Redirecting back to Second Factor Search Page');
150
151
        return $this->redirectToRoute('ra_second_factors_search');
152
    }
153
154
    /**
155
     * @param Request $request