Commit 306ad8ec by Yvon

Revert "comptoir access : instead of allowing all requests from UserAdmin…

Revert "comptoir access : instead of allowing all requests from UserAdmin object, only allow to show password in general user form, which is sufficient to change it ; add tav_env condition"

This reverts commit a6401cfe.
parent 7e5eeabe
...@@ -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,
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Security\Handler; namespace App\Security\Handler;
use App\Application\Sonata\UserBundle\Admin\UserAdmin;
use App\Entity\GlobalParameter; use App\Entity\GlobalParameter;
use App\Entity\User; use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
...@@ -45,7 +46,7 @@ class VoterSecurityHandler extends RoleSecurityHandler ...@@ -45,7 +46,7 @@ class VoterSecurityHandler extends RoleSecurityHandler
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); || $this->allowToChangeAdherentPersonalData($object);
} catch (AuthenticationCredentialsNotFoundException $e) { } catch (AuthenticationCredentialsNotFoundException $e) {
return false; return false;
} }
...@@ -67,15 +68,11 @@ class VoterSecurityHandler extends RoleSecurityHandler ...@@ -67,15 +68,11 @@ class VoterSecurityHandler extends RoleSecurityHandler
return false; return false;
} }
private function allowToModifyAdherentPersonalData($object): bool private function allowToChangeAdherentPersonalData($object): bool
{ {
return $_ENV['TAV_ENV'] //var_dump(get_class($object));
&& $object instanceof User && $object->getAdherent() $res = (($object instanceof User && $object->getAdherent()) || ($object instanceof UserAdmin)) && $this->authorizationChecker->isGranted('ROLE_CHANGE_ADHERENT_PERSONAL_DATA');
&& $this->authorizationChecker->isGranted('ROLE_CHANGE_ADHERENT_PERSONAL_DATA'); //var_dump($res);
} return $res;
public function grantChangeAdherentPasswordToNonSuperAdmin($str): bool
{
return $_ENV['TAV_ENV'] && ($str === 'ROLE_CHANGE_ADHERENT_PERSONAL_DATA');
} }
} }
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