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

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