diff --git a/module/VuFind/src/VuFind/Auth/CAS.php b/module/VuFind/src/VuFind/Auth/CAS.php
index cc3d2da81b89a7031ed8b2cee42c6ede82df7036..eef3d2fd442f3150670b881327b339b3e644a28a 100644
--- a/module/VuFind/src/VuFind/Auth/CAS.php
+++ b/module/VuFind/src/VuFind/Auth/CAS.php
@@ -140,6 +140,7 @@ class CAS extends AbstractBase
             "cat_username", "cat_password", "email", "lastname", "firstname",
             "college", "major", "home_library"
         ];
+        $catPassword = null;
         foreach ($attribsToCheck as $attribute) {
             if (isset($cas->$attribute)) {
                 $value = $casauth->getAttribute($cas->$attribute);
@@ -152,7 +153,7 @@ class CAS extends AbstractBase
         }
 
         // Save credentials if applicable:
-        if (!empty($catPassword) && !empty($user->cat_username)) {
+        if (!empty($user->cat_username)) {
             $user->saveCredentials($user->cat_username, $catPassword);
         }
 
diff --git a/module/VuFind/src/VuFind/Auth/LDAP.php b/module/VuFind/src/VuFind/Auth/LDAP.php
index c80c4fced3e17a2ace878c26ca521446dfb7334e..9bfb8683b4d4a3b19d5e368e0602be4f0dde5a9b 100644
--- a/module/VuFind/src/VuFind/Auth/LDAP.php
+++ b/module/VuFind/src/VuFind/Auth/LDAP.php
@@ -290,7 +290,7 @@ class LDAP extends AbstractBase
         }
 
         // Save credentials if applicable:
-        if (!empty($catPassword) && !empty($user->cat_username)) {
+        if (!empty($user->cat_username)) {
             $user->saveCredentials($user->cat_username, $catPassword);
         }