Code Duplication    Length = 35-35 lines in 2 locations

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

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

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

@@ 103-137 (lines=35) @@
100
     * @param Request $request
101
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
102
     */
103
    public function revokeAction(Request $request)
104
    {
105
        $this->denyAccessUnlessGranted(['ROLE_RA']);
106
107
        $logger = $this->get('logger');
108
109
        $logger->notice('Received request to revoke Second Factor');
110
111
        $command = new RevokeSecondFactorCommand();
112
        $command->currentUserId = $this->getCurrentUser()->id;
113
114
        $form = $this->createForm('ra_revoke_second_factor', $command);
115
        $form->handleRequest($request);
116
117
        $logger->info(sprintf(
118
            'Sending middleware request to revoke Second Factor "%s" belonging to "%s" on behalf of "%s"',
119
            $command->secondFactorId,
120
            $command->identityId,
121
            $command->currentUserId
122
        ));
123
124
        $translator = $this->get('translator');
125
        $flashBag = $this->get('session')->getFlashBag();
126
        if ($this->getSecondFactorService()->revoke($command)) {
127
            $logger->notice('Second Factor revocation Succeeded');
128
            $flashBag->add('success', $translator->trans('ra.second_factor.revocation.revoked'));
129
        } else {
130
            $logger->notice('Second Factor revocation Failed');
131
            $flashBag->add('error', $translator->trans('ra.second_factor.revocation.could_not_revoke'));
132
        }
133
134
        $logger->notice('Redirecting back to Second Factor Search Page');
135
136
        return $this->redirectToRoute('ra_second_factors_search');
137
    }
138
139
    /**
140
     * @param Request $request