Commit f128baaa authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch 'hotline#86381_site' into 'hotline'

hotline #86381 : fix Nanook authentication through ILS only

See merge request !2999
parents cb76fafe 401d5c61
Pipeline #6263 passed with stage
in 33 minutes and 44 seconds
- ticket #86381 : SIGB Nanook : Correction de l'authentification par SIGB uniquement
\ No newline at end of file
...@@ -107,19 +107,34 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac ...@@ -107,19 +107,34 @@ class Class_Webservice_SIGB_Nanook_Service extends Class_WebService_SIGB_Abstrac
* @return Class_WebService_SIGB_Emprunteur * @return Class_WebService_SIGB_Emprunteur
*/ */
public function getEmprunteur($user) { public function getEmprunteur($user) {
if (!$this->ilsdiAuthenticatePatron($user)) if (!$user
|| (!$patron_id = $this->_patronIdFromUser($user)))
return Class_WebService_SIGB_Emprunteur::nullInstance(); 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()) if (!$emprunteur->getCodeBarres())
$emprunteur->setCodeBarres($user->getLogin()); $emprunteur->setCodeBarres($user->getLogin());
$emprunteur->setPassword($user->getPassword()); $emprunteur->setPassword($user->getPassword());
return $emprunteur; 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) { public function getUserAnnexe($user) {
return $user->id_site; return $user->id_site;
} }
......
...@@ -888,6 +888,35 @@ class NanookGetEmprunteurAuthenticateTest extends NanookTestCase { ...@@ -888,6 +888,35 @@ class NanookGetEmprunteurAuthenticateTest extends NanookTestCase {
$this->assertEmpty($emprunteur->getPassword()); $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']));
}
} }
......
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