From 6b1868ea7a9421ac4ea7ff6599f3d9a5fab5a445 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 10 May 2016 16:36:03 +0000 Subject: [PATCH] Bug 16492 - Checkouts ( and possibly checkins and other actions ) will use the patron home branch as the logged in library Bug 14507 introduced the use of checkpw in C4::SIP::ILS::Patron so that non-Koha internal authentication processes would be able to function via SIP ( LDAP et al ). The problem is that checkpw changes the userenv to that of the patron! This is not usually an issue in Koha because most of the time that patron running through checkpw is the one to be logged in. Aside from SIP2 the only other area where this may be an issue is in SCO when using SelfCheckoutByLogin. Test Plan: 1) On master, check out an item to a patron via SIP2 2) Note the checkout lists the item as having been checked out from the patron's home library not matter which library is was supposed to be checked out from. 3) Apply this patch 4) Re-checkout the item 5) The item should now be checked out as if it was checked out from the library as defined in the SIP configuration file. --- C4/Auth.pm | 8 ++++---- C4/SIP/ILS/Patron.pm | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 3081f07..fea6a18 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1734,7 +1734,7 @@ sub get_session { } sub checkpw { - my ( $dbh, $userid, $password, $query, $type ) = @_; + my ( $dbh, $userid, $password, $query, $type, $no_set_context ) = @_; $type = 'opac' unless $type; if ($ldap) { $debug and print STDERR "## checkpw - checking LDAP\n"; @@ -1774,7 +1774,7 @@ sub checkpw { } # INTERNAL AUTH - return checkpw_internal(@_) + return checkpw_internal( $dbh, $userid, $password, $no_set_context) } sub checkpw_internal { @@ -1808,7 +1808,7 @@ sub checkpw_internal { if ( checkpw_hash( $password, $stored_hash ) ) { C4::Context->set_userenv( "$borrowernumber", $userid, $cardnumber, - $firstname, $surname, $branchcode, $branchname, $flags ); + $firstname, $surname, $branchcode, $branchname, $flags ) unless $no_set_context; return 1, $cardnumber, $userid; } } @@ -1825,7 +1825,7 @@ sub checkpw_internal { if ( checkpw_hash( $password, $stored_hash ) ) { C4::Context->set_userenv( $borrowernumber, $userid, $cardnumber, - $firstname, $surname, $branchcode, $branchname, $flags ); + $firstname, $surname, $branchcode, $branchname, $flags ) unless $no_set_context; return 1, $cardnumber, $userid; } } diff --git a/C4/SIP/ILS/Patron.pm b/C4/SIP/ILS/Patron.pm index d61b097..0308006 100644 --- a/C4/SIP/ILS/Patron.pm +++ b/C4/SIP/ILS/Patron.pm @@ -201,7 +201,7 @@ sub check_password { my $dbh = C4::Context->dbh; my $ret = 0; - ($ret) = checkpw( $dbh, $self->{userid}, $pwd ); + ($ret) = checkpw( $dbh, $self->{userid}, $pwd, my $query, my $type, my $no_set_context = 1 ); return $ret; } -- 2.1.4