Commit ca67eb4f by Julien Jorry

BO : empêcher de modifier et/ou supprimer le role SUPER_ADMIN ou ADMIN_SIEGE

parent 6e750b4f
...@@ -109,6 +109,7 @@ class UserAdmin extends BaseUserAdmin ...@@ -109,6 +109,7 @@ class UserAdmin extends BaseUserAdmin
*/ */
protected function configureFormFields(FormMapper $formMapper): void protected function configureFormFields(FormMapper $formMapper): void
{ {
$subject = $this->getSubject();
// define group zoning // define group zoning
$formMapper $formMapper
->tab('User') ->tab('User')
...@@ -116,11 +117,13 @@ class UserAdmin extends BaseUserAdmin ...@@ -116,11 +117,13 @@ class UserAdmin extends BaseUserAdmin
->with('General', ['class' => 'col-md-6'])->end() ->with('General', ['class' => 'col-md-6'])->end()
// ->with('Social', ['class' => 'col-md-6'])->end() // ->with('Social', ['class' => 'col-md-6'])->end()
->end() ->end()
->tab('Security') ->tab('Security');
->with('Groups', ['class' => 'col-md-8'])->end() if (!($subject->isGranted('ROLE_SUPER_ADMIN') || $subject->isGranted('ROLE_ADMIN_SIEGE'))) {
->with('Status', ['class' => 'col-md-4'])->end() $formMapper->with('Groups', ['class' => 'col-md-8'])->end();
}
$formMapper->with('Status', ['class' => 'col-md-4'])->end()
// ->with('Keys', ['class' => 'col-md-4'])->end() // ->with('Keys', ['class' => 'col-md-4'])->end()
->with('Roles', ['class' => 'col-md-12'])->end() // ->with('Roles', ['class' => 'col-md-12'])->end()
->end() ->end()
; ;
...@@ -175,27 +178,28 @@ class UserAdmin extends BaseUserAdmin ...@@ -175,27 +178,28 @@ class UserAdmin extends BaseUserAdmin
->tab('Security') ->tab('Security')
->with('Status') ->with('Status')
->add('enabled', null, ['required' => false]) ->add('enabled', null, ['required' => false])
->end() ->end();
->with('Groups') if (!($subject->isGranted('ROLE_SUPER_ADMIN') || $subject->isGranted('ROLE_ADMIN_SIEGE'))) {
$formMapper->with('Groups')
->add('groups', ModelType::class, [ ->add('groups', ModelType::class, [
'required' => false, 'required' => false,
'expanded' => true, 'expanded' => true,
'multiple' => true, 'multiple' => true,
]) ])
->end() ->end();
->with('Roles') }
->add('realRoles', SecurityRolesType::class, [ // ->with('Roles')
'label' => 'form.label_roles', // ->add('realRoles', SecurityRolesType::class, [
'expanded' => true, // 'label' => 'form.label_roles',
'multiple' => true, // 'expanded' => true,
'required' => false, // 'multiple' => true,
]) // 'required' => false,
->end() // ])
// ->end()
// ->with('Keys') // ->with('Keys')
// ->add('token', null, ['required' => false]) // ->add('token', null, ['required' => false])
// ->add('twoStepVerificationCode', null, ['required' => false]) // ->add('twoStepVerificationCode', null, ['required' => false])
// ->end() // ->end()
->end() $formMapper->end();
;
} }
} }
...@@ -27,7 +27,7 @@ class CRUDController extends Controller ...@@ -27,7 +27,7 @@ class CRUDController extends Controller
return $this->redirectTo($object); return $this->redirectTo($object);
} }
if ($object->hasRoale('ROLE_SUPER_ADMIN') || $object->hasRole('ROLE_ADMIN_SIEGE')) { if ($object->hasRole('ROLE_SUPER_ADMIN') || $object->hasRole('ROLE_ADMIN_SIEGE')) {
$this->addFlash( $this->addFlash(
'sonata_flash_error', 'sonata_flash_error',
'Vous ne pouvez pas supprimer le compte admin !' 'Vous ne pouvez pas supprimer le compte admin !'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment