diff --git a/module/finc/src/finc/Auth/ILS.php b/module/finc/src/finc/Auth/ILS.php index b76f6e95cbf2e0549ff6af32030ac49109cf4b00..c51865d9eeb05fca782d3def84c65aec387b97bf 100644 --- a/module/finc/src/finc/Auth/ILS.php +++ b/module/finc/src/finc/Auth/ILS.php @@ -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( diff --git a/module/finc/src/finc/Auth/ILSAuthenticator.php b/module/finc/src/finc/Auth/ILSAuthenticator.php index ec46cc0e969143197fac749ad078256f865fa46b..8f891bb1eb85bf9e7bcc456132026033d90b6202 100644 --- a/module/finc/src/finc/Auth/ILSAuthenticator.php +++ b/module/finc/src/finc/Auth/ILSAuthenticator.php @@ -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; } } diff --git a/module/finc/src/finc/Auth/ILSAuthenticatorFactory.php b/module/finc/src/finc/Auth/ILSAuthenticatorFactory.php index 1ec9154aa8cb72006ef1a4f6ca3ae9deaa69dec1..d202d0650bd6b11c3be18b0da4eaa9ddee53031d 100644 --- a/module/finc/src/finc/Auth/ILSAuthenticatorFactory.php +++ b/module/finc/src/finc/Auth/ILSAuthenticatorFactory.php @@ -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); }