diff --git a/CHANGELOG.md b/CHANGELOG.md index d5b7391b..5ca66658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.1.2 +**Bugfix** + * Repair the token export feature #234 + ## 3.1.1 **Bugfix** * Remove filter from ra candidate search form #233 diff --git a/src/Surfnet/StepupRa/RaBundle/Command/ExportRaSecondFactorsCommand.php b/src/Surfnet/StepupRa/RaBundle/Command/ExportRaSecondFactorsCommand.php index 59d80a6a..4df93c1a 100644 --- a/src/Surfnet/StepupRa/RaBundle/Command/ExportRaSecondFactorsCommand.php +++ b/src/Surfnet/StepupRa/RaBundle/Command/ExportRaSecondFactorsCommand.php @@ -27,14 +27,6 @@ final class ExportRaSecondFactorsCommand const STATUS_VETTED = 'vetted'; const STATUS_REVOKED = 'revoked'; - /** - * @Assert\NotBlank(message="ra.search_ra_second_factors.institution.blank") - * @Assert\Type("string", message="ra.search_ra_second_factors.institution.type") - * - * @var string - */ - public $actorInstitution; - /** * @Assert\NotBlank(message="ra.search_ra_second_factors.actor.blank") * @Assert\Type("string", message="ra.search_ra_second_factors.actor.type") @@ -104,7 +96,6 @@ public static function fromSearchCommand(SearchRaSecondFactorsCommand $command) { $exportCommand = new self; - $exportCommand->actorInstitution = $command->actorInstitution; $exportCommand->actorId = $command->actorId; $exportCommand->name = $command->name; $exportCommand->type = $command->type; diff --git a/src/Surfnet/StepupRa/RaBundle/Controller/SecondFactorController.php b/src/Surfnet/StepupRa/RaBundle/Controller/SecondFactorController.php index 6d7ae09c..2ea9e958 100644 --- a/src/Surfnet/StepupRa/RaBundle/Controller/SecondFactorController.php +++ b/src/Surfnet/StepupRa/RaBundle/Controller/SecondFactorController.php @@ -60,7 +60,10 @@ public function searchAction(Request $request) // The options that will populate the institution filter choice list. $command->institutionFilterOptions = $secondFactors->getFilterOption('institution'); - $form = $this->createForm(SearchRaSecondFactorsType::class, $command, ['method' => 'get']); + $form = $this->createForm(SearchRaSecondFactorsType::class, $command, [ + 'method' => 'get', + 'enable_export_button' => $this->isGranted(['ROLE_RAA']), + ]); $form->handleRequest($request); $secondFactors = $this->getSecondFactorService()->search($command); @@ -99,7 +102,7 @@ public function searchAction(Request $request) public function exportAction(SearchRaSecondFactorsCommand $command) { - $this->denyAccessUnlessGranted(['ROLE_RA']); + $this->denyAccessUnlessGranted(['ROLE_RAA']); $this->get('logger')->notice('Starting export of searched second factors'); diff --git a/src/Surfnet/StepupRa/RaBundle/Form/Type/SearchRaSecondFactorsType.php b/src/Surfnet/StepupRa/RaBundle/Form/Type/SearchRaSecondFactorsType.php index ddad1f16..944321c9 100644 --- a/src/Surfnet/StepupRa/RaBundle/Form/Type/SearchRaSecondFactorsType.php +++ b/src/Surfnet/StepupRa/RaBundle/Form/Type/SearchRaSecondFactorsType.php @@ -75,33 +75,39 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'required' => false, ]); - $builder->add( - $builder->create( - 'button-group', - FormType::class, - [ - 'inherit_data' => true, - // The empty label ensures the buttons are positioned correctly - 'label' => ' ', - 'widget_form_group_attr' => ['class' => 'form-group button-group'], - ] - ) + $buttonGroup = $builder->create( + 'button-group', + FormType::class, + [ + 'inherit_data' => true, + // The empty label ensures the buttons are positioned correctly + 'label' => ' ', + 'widget_form_group_attr' => ['class' => 'form-group button-group'], + ] + ) ->add('search', SubmitType::class, [ 'label' => 'ra.form.ra_search_ra_second_factors.button.search', 'attr' => [ 'class' => 'btn btn-primary pull-left button-group-member' ], - ]) - ->add('export', SubmitType::class, [ + ]); + + if ($options['enable_export_button']) { + $buttonGroup->add('export', SubmitType::class, [ 'label' => 'ra.form.ra_search_ra_second_factors.button.export', - 'attr' => [ 'class' => 'btn btn-secondary pull-left button-group-member' ], - ]) - ); + 'attr' => ['class' => 'btn btn-secondary pull-left button-group-member'], + ]); + } + + $builder->add($buttonGroup); } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Surfnet\StepupRa\RaBundle\Command\SearchRaSecondFactorsCommand', + 'enable_export_button' => true, ]); + + $resolver->setAllowedTypes('enable_export_button', 'bool'); } public function getBlockPrefix() diff --git a/src/Surfnet/StepupRa/RaBundle/Service/RaSecondFactorService.php b/src/Surfnet/StepupRa/RaBundle/Service/RaSecondFactorService.php index 5f2a66a7..7e7ee51e 100644 --- a/src/Surfnet/StepupRa/RaBundle/Service/RaSecondFactorService.php +++ b/src/Surfnet/StepupRa/RaBundle/Service/RaSecondFactorService.php @@ -146,7 +146,7 @@ public function search(SearchRaSecondFactorsCommand $command) */ public function export(ExportRaSecondFactorsCommand $command) { - $query = new RaSecondFactorExportQuery($command->actorInstitution, $command->actorId); + $query = new RaSecondFactorExportQuery($command->actorId); if ($command->name) { $query->setName($command->name);