diff --git a/VERSIONS b/VERSIONS index 7b8d5b9b9e8a140896b4350d4aab1d78c0a1ce05..c1457b84f9631fd6eee6b6eae7e3607c502cb674 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,8 @@ +05/02/2019 - v8.0.1 + + - ticket #86381 : SIGB Nanook : Correction de l'authentification par SIGB uniquement + + 04/02/2019 - v8.0.0 - ticket #86010 : Administration : activation des fonctionnalités de la version 8.0 . diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index d474d356220777977b0b57bffb85c7b012e3ab32..616186c94f549ce454bb8e4f618efd37449f16e3 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -107,19 +107,34 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac * @return Class_WebService_SIGB_Emprunteur */ public function getEmprunteur($user) { - if (!$this->ilsdiAuthenticatePatron($user)) + if (!$user + || (!$patron_id = $this->_patronIdFromUser($user))) return Class_WebService_SIGB_Emprunteur::nullInstance(); - $emprunteur= $this->ilsdiGetPatronInfo(['patronId' => $user->getIdSigb()], - Class_WebService_SIGB_Nanook_PatronInfoReader::newInstance()); + + $emprunteur = $this->ilsdiGetPatronInfo(['patronId' => $user->getIdSigb()], + Class_WebService_SIGB_Nanook_PatronInfoReader::newInstance()); if (!$emprunteur->getCodeBarres()) $emprunteur->setCodeBarres($user->getLogin()); $emprunteur->setPassword($user->getPassword()); + return $emprunteur; } + protected function _patronIdFromUser($user) { + $patron_id = Class_Users::isLogged($user) + ? $user->getIdSigb() + : ''; + + if (!$patron_id && $this->ilsdiAuthenticatePatron($user)) + $patron_id = $user->getIdSigb(); + + return $patron_id; + } + + public function getUserAnnexe($user) { return $user->id_site; } diff --git a/library/startup.php b/library/startup.php index 79647e8f3346a966951a2554bd3ae0c2629b56ba..25d763e4cc05647d24e3e75da3e5f5f8391ad568 100644 --- a/library/startup.php +++ b/library/startup.php @@ -81,7 +81,7 @@ class Bokeh_Engine { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','8.0'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.0'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.1'); defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/'); diff --git a/tests/library/Class/WebService/SIGB/NanookTest.php b/tests/library/Class/WebService/SIGB/NanookTest.php index be53739a3d0b0833d0495ef77a7145bb47594f8c..53716110fefc694feff85f2dbe62a20d482a9ca9 100644 --- a/tests/library/Class/WebService/SIGB/NanookTest.php +++ b/tests/library/Class/WebService/SIGB/NanookTest.php @@ -888,6 +888,35 @@ class NanookGetEmprunteurAuthenticateTest extends NanookTestCase { $this->assertEmpty($emprunteur->getPassword()); } + + + /** @test */ + public function withLoginThroughSigbOnlyAndAlreadyLoggedShouldNotAuthenticatePatron() { + $this->_mock_web_client + ->whenCalled('open_url') + ->with('http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/999') + ->answers(NanookFixtures::xmlGetPatronError()); + + Class_AdminVar::set('LOGIN_THROUGH_SIGB_ONLY', '1'); + + $user = $this->fixture('Class_Users', + ['id' => 98734, + 'id_site' => 3, + 'idabon' => 'A-00001', + 'id_sigb' => '999', + 'login' => '90175000410218', + 'password' => '', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + ]); + + ZendAfi_Auth::getInstance()->logUser($user); + + $emprunteur = $this->_service->getEmprunteur($user); + + $this->assertTrue($this->_mock_web_client + ->methodHasBeenCalledWithParams('open_url', + ['http://localhost:8080/afi_Nanook/ilsdi/service/GetPatronInfo/patronId/999'])); + } }