Skip to content
Snippets Groups Projects
Commit b1cf5e8a authored by André Lahmann's avatar André Lahmann Committed by Robert Lange
Browse files

refs #21616 [finc] code adjustments regarding https://github.com/vufind-org/vufind/pull/1409

* adapted further code changes from VuFind 6.1.2 to finc module
* add EmailAuthenticator to ILSAuthenticator
parent bc479f3c
Branches
Tags
No related merge requests found
......@@ -120,10 +120,11 @@ class ILS extends \VuFind\Auth\ILS
$user->password = '';
// Update user information based on ILS data:
$fields = ['firstname', 'lastname', 'email', 'major', 'college'];
$fields = ['firstname', 'lastname', 'major', 'college'];
foreach ($fields as $field) {
$user->$field = $info[$field] ?? ' ';
}
$user->updateEmail($info['email'] ?? '');
// Update the user in the database, then return it to the caller:
$user->saveCredentials(
......
......@@ -2,7 +2,7 @@
/**
* Class for managing ILS-specific authentication.
*
* PHP version 5
* PHP version 7
*
* Copyright (C) Villanova University 2007.
*
......@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Authentication
......@@ -27,8 +27,10 @@
*/
namespace finc\Auth;
use VuFind\Auth\EmailAuthenticator as EmailAuthenticator;
use VuFind\Auth\Manager as Manager;
use VuFind\ILS\Connection as ILSConnection;
use Zend\Session\SessionManager as SessionManager;
/**
* Class for managing ILS-specific authentication.
......@@ -58,18 +60,21 @@ class ILSAuthenticator extends \VuFind\Auth\ILSAuthenticator
/**
* Constructor
*
* @param Manager $auth Auth manager
* @param ILSConnection $catalog ILS connection
* @param \Zend\Session\SessionManager $sessionManager Session manager
* @param Manager $auth Auth manager
* @param ILSConnection $catalog ILS connection
* @param SessionManager $sessionManager Session manager
* @param EmailAuthenticator $emailAuth Email authenticator
*/
public function __construct(
Manager $auth,
ILSConnection $catalog,
\Zend\Session\SessionManager $sessionManager
SessionManager $sessionManager,
EmailAuthenticator $emailAuth = null
) {
$this->auth = $auth;
$this->catalog = $catalog;
$this->sessionManager = $sessionManager;
$this->emailAuthenticator = $emailAuth;
}
/**
......@@ -81,7 +86,10 @@ class ILSAuthenticator extends \VuFind\Auth\ILSAuthenticator
{
// SessionContainer not defined yet? Build it now:
if (null === $this->session) {
$this->session = new \Zend\Session\Container('PAIA', $this->sessionManager);
$this->session = new \Zend\Session\Container(
'PAIA',
$this->sessionManager
);
}
return $this->session;
}
......@@ -134,29 +142,22 @@ class ILSAuthenticator extends \VuFind\Auth\ILSAuthenticator
}
/**
* Attempt to log in the user to the ILS, and save credentials if it works.
* Update current user account with the patron information
*
* @param string $username Catalog username
* @param string $password Catalog password
* @param string $catUsername Catalog username
* @param string $catPassword Catalog password
* @param array $patron Patron
*
* Returns associative array of patron data on success, false on failure.
*
* @return array|bool
* @throws ILSException
* @return void
*/
public function newCatalogLogin($username, $password)
protected function updateUser($catUsername, $catPassword, $patron)
{
$result = $this->catalog->patronLogin($username, $password);
if ($result) {
$user = $this->auth->isLoggedIn();
if ($user) {
$user->saveCredentials($username, null);
$this->auth->updateSession($user);
// cache for future use
$this->ilsAccount[$username] = $result;
}
return $result;
$user = $this->auth->isLoggedIn();
if ($user) {
$user->saveCredentials($catUsername, null);
$this->auth->updateSession($user);
// cache for future use
$this->ilsAccount[$catUsername] = $patron;
}
return false;
}
}
......@@ -72,15 +72,16 @@ class ILSAuthenticatorFactory implements FactoryInterface
// actually utilized.
$callback = function (& $wrapped, $proxy) use ($container, $requestedName) {
// Generate wrapped object:
$auth = $container->get('VuFind\Auth\Manager');
$catalog = $container->get('VuFind\ILS\Connection');
$sessionManager = $container->get('VuFind\SessionManager');
$wrapped = new ILSAuthenticator($auth, $catalog, $sessionManager);
$auth = $container->get(\VuFind\Auth\Manager::class);
$catalog = $container->get(\VuFind\ILS\Connection::class);
$emailAuth = $container->get(\VuFind\Auth\EmailAuthenticator::class);
$sessionManager = $container->get(\VuFind\SessionManager::class);
$wrapped = new $requestedName($auth, $catalog, $sessionManager, $emailAuth);
// Indicate that initialization is complete to avoid reinitialization:
$proxy->setProxyInitializer(null);
};
$cfg = $container->get('ProxyManager\Configuration');
$cfg = $container->get(\ProxyManager\Configuration::class);
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($cfg);
return $factory->createProxy($requestedName, $callback);
}
......
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