Loading module/Application/src/Application/Authentication/Storage/AppStorage.php +10 −26 Changes for module/Application/src/Application/Authentication/Storage/AppStorage.php: 10 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -2,10 +2,9 @@ namespace Application\Authentication\Storage; use Application\Entity\UserWrapper; use Application\Entity\Db\Doctorant; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Utilisateur; use Application\Entity\UserWrapper; use Application\Service\Doctorant\DoctorantServiceAwareTrait; use Application\Service\Etablissement\EtablissementServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; Loading @@ -30,14 +29,9 @@ class AppStorage implements ChainableStorage use DoctorantServiceAwareTrait; use EtablissementServiceAwareTrait; const KEY_DB_UTILSATEUR = 'db'; const KEY_DB_UTILISATEUR = 'db'; const KEY_DOCTORANT = 'doctorant'; /** * @var array */ private $contents; /** * @var UserWrapper */ Loading @@ -50,20 +44,16 @@ class AppStorage implements ChainableStorage /** * @param ChainEvent $e * @throws \Zend\Authentication\Exception\ExceptionInterface */ public function read(ChainEvent $e) { $this->contents = $e->getContents(); if (null === $this->contents['ldap'] && null === $this->contents['shib']) { $this->userWrapper = UserWrapper::instFromStorageChainEvent($e); if ($this->userWrapper === null) { return; } $this->userWrapper = UserWrapper::inst($this->contents['ldap'] ?: $this->contents['shib']); /** * Recherche de l'utilisateur connecté dans la table Utilisateur. * Collecte des données issues de la table Utilisateur. */ $this->addDbUtilisateurContents($e); Loading @@ -79,7 +69,7 @@ class AppStorage implements ChainableStorage protected function addDbUtilisateurContents(ChainEvent $e) { try { $e->addContents(self::KEY_DB_UTILSATEUR, $this->fetchUtilisateur()); $e->addContents(self::KEY_DB_UTILISATEUR, $this->fetchUtilisateur()); } catch (ExceptionInterface $e) { throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e); } Loading Loading @@ -116,21 +106,15 @@ class AppStorage implements ChainableStorage return $this->doctorant; } /** * NB: Un doctorant a la possibilité de s'authentifier : * - avec son numéro étudiant (Doctorant::sourceCode), * - avec son persopass (DoctorantCompl::persopass), seulement après qu'il l'a saisi sur la page d'identité de la thèse. */ $username = $this->userWrapper->getUsername(); $id = $this->userWrapper->getSupannId(); $domaineEtab = $this->userWrapper->getDomainFromEppn(); /** @var Etablissement $etablissement */ $etablissement = $this->etablissementService->getRepository()->findOneByDomaine($domaineEtab); $sourceCode = $etablissement->prependPrefixTo($id); try { $this->doctorant = $this->doctorantService->getRepository()->findOneByUsernameAndEtab($username, $etablissement); $this->doctorant = $this->doctorantService->getRepository()->findOneBySourceCode($sourceCode); } catch (NonUniqueResultException $e) { throw new RuntimeException("Plusieurs doctorants ont été trouvés avec le même username: " . $username); throw new RuntimeException("Plusieurs doctorants ont été trouvés avec le même source code: " . $sourceCode); } return $this->doctorant; Loading module/Application/src/Application/Entity/Db/Individu.php +3 −3 Changes for module/Application/src/Application/Entity/Db/Individu.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -284,11 +284,11 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface /** * Set civilite * * @param string $civilite * @param string|null $civilite * * @return self */ public function setCivilite($civilite) public function setCivilite($civilite = null) { $this->civilite = $civilite; Loading @@ -298,7 +298,7 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface /** * Get civilite * * @return string * @return string|null */ public function getCivilite() { Loading module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Individu.dcm.xml +1 −1 Changes for module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Individu.dcm.xml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ <generator strategy="SEQUENCE"/> </id> <field name="civilite" type="string" column="CIVILITE" length="5" nullable="false"/> <field name="civilite" type="string" column="CIVILITE" length="5" nullable="true"/> <field name="dateNaissance" type="datetime" column="DATE_NAISSANCE" nullable="false"/> <field name="nationalite" type="string" column="NATIONALITE" nullable="true"/> <field name="email" type="string" column="EMAIL" length="255" nullable="true"/> Loading module/Application/src/Application/Entity/Db/Repository/DoctorantRepository.php +6 −9 Changes for module/Application/src/Application/Entity/Db/Repository/DoctorantRepository.php: 6 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -3,27 +3,24 @@ namespace Application\Entity\Db\Repository; use Application\Entity\Db\Doctorant; use Application\Entity\Db\Etablissement; use Doctrine\ORM\NonUniqueResultException; class DoctorantRepository extends DefaultEntityRepository { /** * @param string $username * @param Etablissement $etablissement * @param string $sourceCode * @return Doctorant * @throws NonUniqueResultException */ public function findOneByUsernameAndEtab($username, Etablissement $etablissement) public function findOneBySourceCode($sourceCode) { $qb = $this->createQueryBuilder('t'); $qb ->leftJoin('t.complements', 'c') ->addSelect('i') ->join('t.individu', 'i') ->where('t.sourceCode = :sourceCode') ->andWhere('1 = pasHistorise(t)') // todo: ajouter le code étab au persopass enregistré dans la table DOCTORANT_COMPL ->andWhere('t.sourceCode = :sourceCode OR c.persopass = :persopass') ->setParameter('sourceCode', $etablissement->getCode() . '::' . $username) ->setParameter('persopass', $username); ->setParameter('sourceCode', $sourceCode); return $qb->getQuery()->getOneOrNullResult(); } Loading module/Application/src/Application/Entity/Db/Repository/IndividuRepository.php +3 −5 Changes for module/Application/src/Application/Entity/Db/Repository/IndividuRepository.php: 3 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Application\Entity\Db\Repository; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Individu; use Doctrine\DBAL\DBALException; use UnicaenApp\Exception\RuntimeException; Loading @@ -11,14 +10,13 @@ use UnicaenApp\Util; class IndividuRepository extends DefaultEntityRepository { /** * @param string $empId * @param Etablissement $etablissement * @param string $sourceCode * @return Individu */ public function findOneByEmpIdAndEtab($empId, Etablissement $etablissement) public function findOneBySourceCode($sourceCode) { /** @var Individu $i */ $i = $this->findOneBy(['sourceCode' => $etablissement->getCode() . '::' . $empId]); $i = $this->findOneBy(['sourceCode' => $sourceCode]); return $i; } Loading Loading
module/Application/src/Application/Authentication/Storage/AppStorage.php +10 −26 Changes for module/Application/src/Application/Authentication/Storage/AppStorage.php: 10 added lines, 26 removed lines. Original line number Diff line number Diff line Loading @@ -2,10 +2,9 @@ namespace Application\Authentication\Storage; use Application\Entity\UserWrapper; use Application\Entity\Db\Doctorant; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Utilisateur; use Application\Entity\UserWrapper; use Application\Service\Doctorant\DoctorantServiceAwareTrait; use Application\Service\Etablissement\EtablissementServiceAwareTrait; use Application\Service\Utilisateur\UtilisateurServiceAwareTrait; Loading @@ -30,14 +29,9 @@ class AppStorage implements ChainableStorage use DoctorantServiceAwareTrait; use EtablissementServiceAwareTrait; const KEY_DB_UTILSATEUR = 'db'; const KEY_DB_UTILISATEUR = 'db'; const KEY_DOCTORANT = 'doctorant'; /** * @var array */ private $contents; /** * @var UserWrapper */ Loading @@ -50,20 +44,16 @@ class AppStorage implements ChainableStorage /** * @param ChainEvent $e * @throws \Zend\Authentication\Exception\ExceptionInterface */ public function read(ChainEvent $e) { $this->contents = $e->getContents(); if (null === $this->contents['ldap'] && null === $this->contents['shib']) { $this->userWrapper = UserWrapper::instFromStorageChainEvent($e); if ($this->userWrapper === null) { return; } $this->userWrapper = UserWrapper::inst($this->contents['ldap'] ?: $this->contents['shib']); /** * Recherche de l'utilisateur connecté dans la table Utilisateur. * Collecte des données issues de la table Utilisateur. */ $this->addDbUtilisateurContents($e); Loading @@ -79,7 +69,7 @@ class AppStorage implements ChainableStorage protected function addDbUtilisateurContents(ChainEvent $e) { try { $e->addContents(self::KEY_DB_UTILSATEUR, $this->fetchUtilisateur()); $e->addContents(self::KEY_DB_UTILISATEUR, $this->fetchUtilisateur()); } catch (ExceptionInterface $e) { throw new RuntimeException("Erreur imprévue rencontrée.", 0, $e); } Loading Loading @@ -116,21 +106,15 @@ class AppStorage implements ChainableStorage return $this->doctorant; } /** * NB: Un doctorant a la possibilité de s'authentifier : * - avec son numéro étudiant (Doctorant::sourceCode), * - avec son persopass (DoctorantCompl::persopass), seulement après qu'il l'a saisi sur la page d'identité de la thèse. */ $username = $this->userWrapper->getUsername(); $id = $this->userWrapper->getSupannId(); $domaineEtab = $this->userWrapper->getDomainFromEppn(); /** @var Etablissement $etablissement */ $etablissement = $this->etablissementService->getRepository()->findOneByDomaine($domaineEtab); $sourceCode = $etablissement->prependPrefixTo($id); try { $this->doctorant = $this->doctorantService->getRepository()->findOneByUsernameAndEtab($username, $etablissement); $this->doctorant = $this->doctorantService->getRepository()->findOneBySourceCode($sourceCode); } catch (NonUniqueResultException $e) { throw new RuntimeException("Plusieurs doctorants ont été trouvés avec le même username: " . $username); throw new RuntimeException("Plusieurs doctorants ont été trouvés avec le même source code: " . $sourceCode); } return $this->doctorant; Loading
module/Application/src/Application/Entity/Db/Individu.php +3 −3 Changes for module/Application/src/Application/Entity/Db/Individu.php: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -284,11 +284,11 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface /** * Set civilite * * @param string $civilite * @param string|null $civilite * * @return self */ public function setCivilite($civilite) public function setCivilite($civilite = null) { $this->civilite = $civilite; Loading @@ -298,7 +298,7 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface /** * Get civilite * * @return string * @return string|null */ public function getCivilite() { Loading
module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Individu.dcm.xml +1 −1 Changes for module/Application/src/Application/Entity/Db/Mapping/Application.Entity.Db.Individu.dcm.xml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ <generator strategy="SEQUENCE"/> </id> <field name="civilite" type="string" column="CIVILITE" length="5" nullable="false"/> <field name="civilite" type="string" column="CIVILITE" length="5" nullable="true"/> <field name="dateNaissance" type="datetime" column="DATE_NAISSANCE" nullable="false"/> <field name="nationalite" type="string" column="NATIONALITE" nullable="true"/> <field name="email" type="string" column="EMAIL" length="255" nullable="true"/> Loading
module/Application/src/Application/Entity/Db/Repository/DoctorantRepository.php +6 −9 Changes for module/Application/src/Application/Entity/Db/Repository/DoctorantRepository.php: 6 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -3,27 +3,24 @@ namespace Application\Entity\Db\Repository; use Application\Entity\Db\Doctorant; use Application\Entity\Db\Etablissement; use Doctrine\ORM\NonUniqueResultException; class DoctorantRepository extends DefaultEntityRepository { /** * @param string $username * @param Etablissement $etablissement * @param string $sourceCode * @return Doctorant * @throws NonUniqueResultException */ public function findOneByUsernameAndEtab($username, Etablissement $etablissement) public function findOneBySourceCode($sourceCode) { $qb = $this->createQueryBuilder('t'); $qb ->leftJoin('t.complements', 'c') ->addSelect('i') ->join('t.individu', 'i') ->where('t.sourceCode = :sourceCode') ->andWhere('1 = pasHistorise(t)') // todo: ajouter le code étab au persopass enregistré dans la table DOCTORANT_COMPL ->andWhere('t.sourceCode = :sourceCode OR c.persopass = :persopass') ->setParameter('sourceCode', $etablissement->getCode() . '::' . $username) ->setParameter('persopass', $username); ->setParameter('sourceCode', $sourceCode); return $qb->getQuery()->getOneOrNullResult(); } Loading
module/Application/src/Application/Entity/Db/Repository/IndividuRepository.php +3 −5 Changes for module/Application/src/Application/Entity/Db/Repository/IndividuRepository.php: 3 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Application\Entity\Db\Repository; use Application\Entity\Db\Etablissement; use Application\Entity\Db\Individu; use Doctrine\DBAL\DBALException; use UnicaenApp\Exception\RuntimeException; Loading @@ -11,14 +10,13 @@ use UnicaenApp\Util; class IndividuRepository extends DefaultEntityRepository { /** * @param string $empId * @param Etablissement $etablissement * @param string $sourceCode * @return Individu */ public function findOneByEmpIdAndEtab($empId, Etablissement $etablissement) public function findOneBySourceCode($sourceCode) { /** @var Individu $i */ $i = $this->findOneBy(['sourceCode' => $etablissement->getCode() . '::' . $empId]); $i = $this->findOneBy(['sourceCode' => $sourceCode]); return $i; } Loading