Commit 558ec245 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Nouveau rôle 'Authentifié(e)' permettant d'ajuster les privilèges d'un simple...

Nouveau rôle 'Authentifié(e)' permettant d'ajuster les privilèges d'un simple utilisateur authentifié.
parent a25ebb1d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ class Role extends AbstractRole implements SourceAwareInterface, HistoriqueAware
    const CODE_ED = 'ED';
    const CODE_UR = 'UR';

    const ROLE_ID_USER = 'user'; // ROLE_ID du rôle correspondant à un utilisateur authentifié avec succès.

    // @todo NB: maintenant il y le code étab concaténé au "role_id"
    const ROLE_ID_DOCTORANT = "Doctorant";
    const ROLE_ID_BUREAU_DES_DOCTORATS = "Maison du doctorat";
+8 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Application\SourceCodeStringHelperAwareTrait;
use BjyAuthorize\Provider\Identity\ProviderInterface;
use UnicaenAuth\Acl\NamedRole;
use UnicaenAuth\Provider\Identity\ChainableProvider;
use UnicaenAuth\Provider\Identity\ChainEvent;
use Zend\Authentication\AuthenticationService;
@@ -91,10 +92,14 @@ class IdentityProvider implements ProviderInterface, ChainableProvider
            return [];
        }

        $this->roles = array_merge([],
            $this->getRolesFromActeur(),
        $roleAuthentifie = $this->roleService->getRepository()->findByCode('user')/*->setLibelle("coucou")*/;

        $this->roles = array_merge(
            [$roleAuthentifie],
//            $this->getRolesFromActeur(),
            $this->getRolesFromIndividuRole(),
            $this->getRolesFromDoctorant());
//            $this->getRolesFromDoctorant()
        );

// Lignes mises en commentaire car revient à considérer le rôle "BdD UCN" identique au rôle "BdD URN" !
// La question est: pourquoi avoir fait ça ?
+15 −3
Original line number Diff line number Diff line
@@ -3,13 +3,12 @@
namespace Application\Service;

use Application\Authentication\Storage\AppStorage;
use Application\Entity\Db\These;
use Application\Entity\UserWrapper;
use Application\Entity\Db\Doctorant;
use Application\Entity\Db\Etablissement;
use Application\Entity\Db\Individu;
use Application\Entity\Db\Role;
use Application\Entity\Db\These;
use Application\Entity\Db\Utilisateur;
use Application\Entity\UserWrapper;
use Application\Entity\UserWrapperFactory;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
@@ -25,6 +24,19 @@ class UserContextService extends BaseUserContextService
    use EtablissementServiceAwareTrait;
    use SourceCodeStringHelperAwareTrait;

    /**
     * @inheritDoc
     */
    public function getSelectableIdentityRoles()
    {
        return array_filter($this->getIdentityRoles(), function($r) {
            if ($r instanceof RoleInterface && $r->getRoleId() === Role::ROLE_ID_USER) {
                return false;
            }
            return true;
        });
    }

    /**
     * @return Role|RoleInterface|null
     */