Prevent a user from lock itself out from the user system.

This commit is contained in:
Jan Böhmer 2019-09-11 18:50:23 +02:00
parent 856e20586f
commit 90d449ea22
6 changed files with 164 additions and 1 deletions

View file

@ -33,10 +33,12 @@ namespace App\Form\Permissions;
use App\Services\PermissionResolver;
use App\Validator\Constraints\NoLockout;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
class PermissionsType extends AbstractType
@ -54,8 +56,16 @@ class PermissionsType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'show_legend' => true
'show_legend' => true,
'constraints' => function (Options $options) {
if (!$options['disabled']) {
return [new NoLockout()];
}
return [];
}
]);
}
public function buildView(FormView $view, FormInterface $form, array $options)