Code Duplication    Length = 35-35 lines in 2 locations

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

@@ 178-212 (lines=35) @@
175
     * @param Request $request
176
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
177
     */
178
    public function removeAction(Request $request)
179
    {
180
        $this->denyAccessUnlessGranted(['ROLE_RA']);
181
182
        $logger = $this->get('logger');
183
184
        $logger->notice('Received request to remove RA location');
185
186
        $command = new RemoveRaLocationCommand();
187
        $command->currentUserId = $this->getCurrentUser()->id;
188
189
        $form = $this->createForm(RemoveRaLocationType::class, $command);
190
        $form->handleRequest($request);
191
192
        $logger->info(sprintf(
193
            'Sending middleware request to remove RA location "%s" belonging to "%s" on behalf of "%s"',
194
            $command->locationId,
195
            $command->institution,
196
            $command->currentUserId
197
        ));
198
199
        $translator = $this->get('translator');
200
        $flashBag = $this->get('session')->getFlashBag();
201
        if ($this->getRaLocationService()->remove($command)) {
202
            $logger->notice('RA Location removal Succeeded');
203
            $flashBag->add('success', $translator->trans('ra.ra_location.revocation.removed'));
204
        } else {
205
            $logger->notice('RA Location removal Failed');
206
            $flashBag->add('error', $translator->trans('ra.ra_location.revocation.could_not_remove'));
207
        }
208
209
        $logger->notice('Redirecting back to RA Location Manage Page');
210
211
        return $this->redirectToRoute('ra_locations_manage');
212
    }
213
214
    /**
215
     * @return \Surfnet\StepupRa\RaBundle\Service\RaLocationService

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

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