Commit 0a7b3ecd by Damien Moulard

Merge branch '4286-annulation-modifications-4176' into 'develop'

4286 annulation modifications 4176

See merge request cooperatic/kohinos-tav!24
parents 368bf173 8e1b51c6
...@@ -131,8 +131,7 @@ App\Entity\Usergroup: ...@@ -131,8 +131,7 @@ App\Entity\Usergroup:
'ROLE_ADMIN_PRESTATAIRE_GERER_EDIT', 'ROLE_ADMIN_PRESTATAIRE_GERER_EDIT',
'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_EDIT', 'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_EDIT',
'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_LIST', 'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_LIST',
'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_CREATE', 'ROLE_ADMIN_PRESTATAIRE_COTISATIONS_CREATE']]
'ROLE_CHANGE_ADHERENT_PERSONAL_DATA']]
usergroup_contact: usergroup_contact:
__construct: ['Contact', [ __construct: ['Contact', [
'ROLE_CONTACT', 'ROLE_CONTACT',
......
...@@ -194,10 +194,7 @@ class UserAdmin extends BaseUserAdmin ...@@ -194,10 +194,7 @@ class UserAdmin extends BaseUserAdmin
->add('username') ->add('username')
->add('email') ->add('email')
; ;
if ( if ('dev' == $_ENV['APP_ENV'] && $this->isGranted('ROLE_SUPER_ADMIN')) {
'dev' == $_ENV['APP_ENV'] && ($this->isGranted('ROLE_SUPER_ADMIN')
|| $this->getSecurityHandler()->grantChangeAdherentPasswordToNonSuperAdmin('ROLE_CHANGE_ADHERENT_PERSONAL_DATA'))
) {
$formMapper $formMapper
->add('plainPassword', RepeatedType::class, [ ->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class, 'type' => PasswordType::class,
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace App\Security\Handler; namespace App\Security\Handler;
use App\Entity\GlobalParameter; use App\Entity\GlobalParameter;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Sonata\AdminBundle\Admin\AdminInterface; use Sonata\AdminBundle\Admin\AdminInterface;
use Sonata\AdminBundle\Security\Handler\RoleSecurityHandler; use Sonata\AdminBundle\Security\Handler\RoleSecurityHandler;
...@@ -44,8 +43,7 @@ class VoterSecurityHandler extends RoleSecurityHandler ...@@ -44,8 +43,7 @@ class VoterSecurityHandler extends RoleSecurityHandler
try { try {
return $this->isAnyGranted($this->superAdminRoles) return $this->isAnyGranted($this->superAdminRoles)
|| $this->isAnyGranted($attributes, $object) || $this->isAnyGranted($attributes, $object)
|| $this->isAnyGranted([$allRole], $object) || $this->isAnyGranted([$allRole], $object);
|| $this->allowToModifyAdherentPersonalData($object);
} catch (AuthenticationCredentialsNotFoundException $e) { } catch (AuthenticationCredentialsNotFoundException $e) {
return false; return false;
} }
...@@ -66,16 +64,4 @@ class VoterSecurityHandler extends RoleSecurityHandler ...@@ -66,16 +64,4 @@ class VoterSecurityHandler extends RoleSecurityHandler
return false; return false;
} }
private function allowToModifyAdherentPersonalData($object): bool
{
return $_ENV['TAV_ENV']
&& $object instanceof User && $object->getAdherent()
&& $this->authorizationChecker->isGranted('ROLE_CHANGE_ADHERENT_PERSONAL_DATA');
}
public function grantChangeAdherentPasswordToNonSuperAdmin($str): bool
{
return $_ENV['TAV_ENV'] && $this->authorizationChecker->isGranted($str);
}
} }
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