From 9e760e17521f08ea84620bd0488487ac96392df7 Mon Sep 17 00:00:00 2001 From: Sebastian Kehr <kehr@ub.uni-leipzig.de> Date: Mon, 11 Dec 2017 16:39:17 +0100 Subject: [PATCH] Use configured username field when updating password. --- module/VuFind/src/VuFind/Auth/ILS.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/module/VuFind/src/VuFind/Auth/ILS.php b/module/VuFind/src/VuFind/Auth/ILS.php index a36db29c27d..95671c9ce8d 100644 --- a/module/VuFind/src/VuFind/Auth/ILS.php +++ b/module/VuFind/src/VuFind/Auth/ILS.php @@ -202,7 +202,8 @@ class ILS extends AbstractBase } // Update the user and send it back to the caller: - $user = $this->getUserTable()->getByUsername($patron['cat_username']); + $username = $patron[$this->getUsernameField()]; + $user = $this->getUserTable()->getByUsername($username); $user->saveCredentials($patron['cat_username'], $params['password']); return $user; } @@ -219,9 +220,7 @@ class ILS extends AbstractBase { // Figure out which field of the response to use as an identifier; fail // if the expected field is missing or empty: - $config = $this->getConfig(); - $usernameField = isset($config->Authentication->ILS_username_field) - ? $config->Authentication->ILS_username_field : 'cat_username'; + $usernameField = $this->getUsernameField(); if (!isset($info[$usernameField]) || empty($info[$usernameField])) { throw new AuthException('authentication_error_technical'); } @@ -289,4 +288,16 @@ class ILS extends AbstractBase $patron = $this->authenticator->storedCatalogLogin(); return $patron ? $patron : null; } + + /** + * Gets the configured username field. + * + * @return string + */ + protected function getUsernameField() + { + $config = $this->getConfig(); + return isset($config->Authentication->ILS_username_field) + ? $config->Authentication->ILS_username_field : 'cat_username'; + } } -- GitLab