Commit 5c7f0fd5 authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch 'hotline#86474_probleme_compte_lecteur' into 'hotline'

hotline #86474 : fix multicards with login through ILS only

See merge request !3002
parents f29cb9e2 f7cc9c74
Pipeline #6279 passed with stage
in 34 minutes and 2 seconds
- ticket #86474 : Compte lecteur : Correction de la compatibilité du multi-carte avec l'authentification par le SIGB uniquement
\ No newline at end of file
......@@ -61,11 +61,12 @@ class AbonneController extends ZendAfi_Controller_Action {
protected function clearEmprunteurCache() {
if (in_array($this->getRequest()->getActionName(), ['prets',
'reservations',
'fiche',
'loans-history']))
Class_WebService_SIGB_EmprunteurCache::newInstance()->remove($this->_user);
if (!in_array($this->getRequest()->getActionName(),
['prets', 'reservations', 'fiche', 'loans-history']))
return;
foreach((new Class_User_Cards($this->_user)) as $user)
Class_WebService_SIGB_EmprunteurCache::newInstance()->remove($user);
}
......@@ -1224,14 +1225,13 @@ class AbonneController extends ZendAfi_Controller_Action {
$this->view->form = $form;
if (!$this->_request->isPost() || !$form->isValid($this->_request->getPost()))
return $this;
if ((!$child = Class_Users::findFirstBy(['login' => $this->_getPost('login'),
'password' => $this->_getPost('password')]))
|| !$child->isAbonne()) {
$child = Class_Auth::getInstance()
->authenticateLoginPassword($this->_getPost('login'), $this->_getPost('password'));
if (!$child || !$child->isAbonne()) {
$this->_helper->notify($this->_('Identifiant et/ou mot de passe incorrect'));
return $this->_redirect('/abonne/add-card');
}
......
<?php
/**
* Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_Auth {
use Trait_Singleton;
public function authenticateLoginPassword($login, $password) {
$adapters = [new ZendAfi_Auth_Adapter_CommSigb(),
new ZendAfi_Auth_Adapter_DbTable()];
foreach ($adapters as $adapter) {
if ((new ZendAfi_Auth_TryHarder($this, $adapter))->tryHarder($login, $password))
return $adapter->getAuthenticatedUser();;
if ($adapter->shouldBreakChain())
return;
}
}
public function authenticate($adapter) {
return $adapter->authenticate();
}
}
......@@ -32,7 +32,10 @@ class Class_User_Cards extends Storm_Model_Collection {
public function getLoansWithOutPNB($params = []) {
return $this->_decorateOperationFrom(function($card) use ($params) { return $card->getLoansWithOutPNB($params); });
return $this->_decorateOperationFrom(
function($card) use ($params) {
return $card->getLoansWithOutPNB($params);
});
}
......
......@@ -125,13 +125,16 @@ class UsersLoader extends Storm_Model_Loader {
public function isLogged($user) {
if(!$user)
if (!$user)
return false;
if(!$logged_user = Class_Users::getIdentity())
if (!$logged_user = Class_Users::getIdentity())
return false;
return $user->getId() == $logged_user->getId();
if ($user->getId() == $logged_user->getId())
return true;
return $user->isChildOf($logged_user);
}
......@@ -1902,4 +1905,13 @@ class Class_Users extends Storm_Model_Abstract {
public function isSIGBProvidesChangePasswordService() {
return ($sigb_com = $this->getSIGBComm()) && $sigb_com->providesChangePasswordService();
}
public function isChildOf($other) {
foreach($this->getParentCards() as $parent)
if ($parent->getId() == $other->getId())
return true;
return false;
}
}
......@@ -57,4 +57,10 @@ abstract class ZendAfi_Auth_Adapter_Abstract implements Zend_Auth_Adapter_Interf
public function getResultObject() {
return $this->_authenticated_user->toStdClass();
}
/** @return Class_Users */
public function getAuthenticatedUser() {
return $this->_authenticated_user;
}
}
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