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

@@ 83-117 (lines=35) @@
80
     * @param Request $request
81
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
82
     */
83
    public function revokeAction(Request $request)
84
    {
85
        $this->denyAccessUnlessGranted(['ROLE_RA']);
86
87
        $logger = $this->get('logger');
88
89
        $logger->notice('Received request to revoke Second Factor');
90
91
        $command = new RevokeSecondFactorCommand();
92
        $command->currentUserId = $this->getCurrentUser()->id;
93
94
        $form = $this->createForm('ra_revoke_second_factor', $command);
95
        $form->handleRequest($request);
96
97
        $logger->info(sprintf(
98
            'Sending middleware request to revoke Second Factor "%s" belonging to "%s" on behalf of "%s"',
99
            $command->secondFactorId,
100
            $command->identityId,
101
            $command->currentUserId
102
        ));
103
104
        $translator = $this->get('translator');
105
        $flashBag = $this->get('session')->getFlashBag();
106
        if ($this->getSecondFactorService()->revoke($command)) {
107
            $logger->notice('Second Factor revocation Succeeded');
108
            $flashBag->add('success', $translator->trans('ra.second_factor.revocation.revoked'));
109
        } else {
110
            $logger->notice('Second Factor revocation Failed');
111
            $flashBag->add('error', $translator->trans('ra.second_factor.revocation.could_not_revoke'));
112
        }
113
114
        $logger->notice('Redirecting back to Second Factor Search Page');
115
116
        return $this->redirectToRoute('ra_second_factors_search');
117
    }
118
119
    /**
120
     * @param Request $request