Commit 451cf72c authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Ajout d'une option pour normaliser la relation Person <> Authentification

parent f9ffcfee
Loading
Loading
Loading
Loading
+4 −0
Changes for config/autoload/global.php: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -25,6 +25,10 @@ return array(
        ///
        'oscar_num_separator' => 'DRI',

        ////////////////////////////////////////////////////////////////////////////////// authPersonNormalize [boolean]
        /// Permet d'ignorer la casse lors de la jonction entre les personnes et l'authentification
        'authPersonNormalize' => false,


        'export' => [
            'payments' => [
+2 −4
Changes for module/Oscar/src/Oscar/Service/OscarUserContext.php: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -283,7 +283,7 @@ class OscarUserContext extends UserContext
        $person = $person == null ? $this->getCurrentPerson() : $person;
        /** @var OrganizationPerson $affectation */
        foreach ($person->getOrganizations() as $affectation) {
            if( $affectation->isPrincipal() )
            if( !$affectation->isOutOfDate() && $affectation->isPrincipal() )
                $organizations[] = $id === true ? $affectation->getOrganization()->getId() : $affectation->getOrganization();
        }

@@ -304,7 +304,7 @@ class OscarUserContext extends UserContext
        $rolesLead = $this->getRoleIdPrimary();
        /** @var OrganizationPerson $affectation */
        foreach ($person->getOrganizations() as $affectation) {
            if (in_array($affectation->getRole(), $rolesLead)) {
            if (!$affectation->isOutOfDate() && in_array($affectation->getRole(), $rolesLead)) {
                return true;
            }
        }
@@ -349,7 +349,6 @@ class OscarUserContext extends UserContext

        try {
            if ($this->getLdapUser()) {

                // PATCH Limoges
                // au cas ou le supannAliasLogin n'est pas fournis...
                $pseudo = $this->getLdapUser()->getSupannAliasLogin();
@@ -363,7 +362,6 @@ class OscarUserContext extends UserContext
        } catch (NoResultException $ex) {
            // ... can happening with users stored in database directly
        }

        return null;
    }

+25 −6
Changes for module/Oscar/src/Oscar/Service/PersonService.php: 25 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -43,6 +43,16 @@ class PersonService implements ServiceLocatorAwareInterface, EntityManagerAwareI
    use ServiceLocatorAwareTrait, EntityManagerAwareTrait;


    /**
     * Retourne la configuration OSCAR.
     *
     * @return ConfigurationParser
     */
    protected function getOscarConfig()
    {
        return $this->getServiceLocator()->get('OscarConfig');
    }

    /**
     * @return PersonRepository
     */
@@ -402,12 +412,21 @@ class PersonService implements ServiceLocatorAwareInterface, EntityManagerAwareI
        }

        if( !isset($this->_cachePersonLdapLogin[$login]) ){
            // $this->getServiceLocator()->get('Logger')->info('Request BDD with ' . $login);
            $this->_cachePersonLdapLogin[$login] = $this->getBaseQuery()
                ->where('p.ladapLogin = :login')
                ->setParameter('login', $login)
                ->getQuery()
                ->getSingleResult();
            $query = $this->getBaseQuery()
                ->setParameter('login', $login);

            $normalize = $this->getOscarConfig()->getConfiguration('authPersonNormalize', false);

            if( $normalize == true ){
                
                $query->where('LOWER(p.ladapLogin) = :login')
                    ->setParameter('login', strtolower($login));
            } else {
                $query->where('p.ladapLogin = :login')
                    ->setParameter('login', $login);
            }

            $this->_cachePersonLdapLogin[$login] = $query->getQuery()->getSingleResult();
        }
        return $this->_cachePersonLdapLogin[$login];
    }