From 259e186b5acd4903249e96e0ceb997becbc9d4e9 Mon Sep 17 00:00:00 2001 From: Oliver Bock Date: Thu, 6 Jul 2017 18:37:42 +0000 Subject: [PATCH] Bug 18880: Regression breaks local authentication fallback for all external authentications A regression in commit cfc484b17 / bug #18314 breaks the local authentication fallback for all external authentications like LDAP, CAS and Shibboleth. The severity is critical for us as we, while using LDAP authentication, use the self-service checkout which requires a local user account. Also non-LDAP staff can't log into the staff pages anymore. The regression itself is a logical error as "@return = (0)" is considered to be "false" when checked with "unless". That's wrong as "unless" tests the number of elements in a list. Thus the "falsy" condition has to established with "@return = ()" instead. Please find attached a proposed patch against "17.05.x". Also, please make sure the fallback workflow gets test coverage. --- C4/Auth.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index e7b0895160..2e014c2237 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1764,14 +1764,14 @@ sub checkpw { my $patron = Koha::Patrons->find({ userid => $userid }); if ( $patron and $patron->account_locked ) { - @return = (0); + @return = (); } elsif ($ldap) { $debug and print STDERR "## checkpw - checking LDAP\n"; my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH if ( $retval ) { @return = ( $retval, $retcard, $retuserid ); } else { - @return = (0); + @return = (); } } elsif ( $cas && $query && $query->param('ticket') ) { @@ -1784,7 +1784,7 @@ sub checkpw { if ( $retval ) { @return = ( $retval, $retcard, $retuserid ); } else { - @return = (0); + @return = (); } } @@ -1805,7 +1805,7 @@ sub checkpw { if ( $retval ) { @return = ( $retval, $retcard, $retuserid ); } else { - @return = (0); + @return = (); } } } -- 2.11.0