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