Bug 21046: Return the correct borrowernumber when there is empty cardnumber(s)

Test plan:
  - Use a patron with an empty cardnumber to authenticate with ILSDI
    AuthenticatePatron
    (cgi-bin/koha/ilsdi.pl?service=AuthenticatePatron&username=userid&password=pass),
  - make sure you have other patron(s) with empty cardnumber and there
    borrowernumber is
    smaller than the one you authenticate with,
  - you should get a wrong borrowernumber,
  - apply this patch,
  - test again, you should get the right one

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Alex Arnaud 2018-07-06 13:40:53 +00:00 committed by Martin Renvoize
parent b056933a36
commit e7501a92aa
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 9 additions and 1 deletions

View File

@ -357,7 +357,7 @@ sub AuthenticatePatron {
my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password );
if ( $status ) {
# Get the borrower
my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
my $patron = Koha::Patrons->find( { userid => $userid } );
return { id => $patron->borrowernumber };
}
else {

View File

@ -42,9 +42,17 @@ subtest 'AuthenticatePatron test' => sub {
my $plain_password = 'tomasito';
$builder->build({
source => 'Borrower',
value => {
cardnumber => undef,
}
});
my $borrower = $builder->build({
source => 'Borrower',
value => {
cardnumber => undef,
password => Koha::AuthUtils::hash_password( $plain_password )
}
});