Bug 35918: Fix auto library connect (AutoLocation)
This code is a bit weird, its purpose it to auto select the library depending on the IP. A problem appears if the same IP is used, then the user's choice will might be overwritten randomly by another library. To recreate the problem: Turn on AutoLocation Use koha/koha @CPL for test And the following config: *************************** 1. row *************************** branchcode: CPL branchname: Centerville branchip: 172.18.0.1 *************************** 2. row *************************** branchcode: FFL branchname: Fairfield branchip: 172.18.0.1 *************************** 3. row *************************** branchcode: FPL branchname: Fairview branchip: 172.18.0.4 Connect and select CPL. Randomly FFL will be picked instead. Signed-off-by: Magnus Enger <magnus@libriotech.no> Tested this on top of 35890 and 35904 because git bz said they were required dependencies. Figured out the IP Koha was seeing me as coming from in /var/log/koha/kohadev/plack.log. Added that IP to the branchip for Centerville, Fairfield and Fairview. Set AutoLocation = Yes. After this I could recreate the problem: If i left the "Library" field in the login screen at "My Library" I got logged into a random library selected from the three i had set branchip for. Applying the patches fixed this, as expected. Tests pass, with AutoLocation off. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> (cherry picked from commit 4efe74fe12075298680965db3605f717f1da10d0) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
parent
41100322f8
commit
b2c89a5ae0
1 changed files with 11 additions and 7 deletions
18
C4/Auth.pm
18
C4/Auth.pm
|
@ -26,6 +26,7 @@ use CGI::Session;
|
||||||
use CGI::Session::ErrorHandler;
|
use CGI::Session::ErrorHandler;
|
||||||
use URI;
|
use URI;
|
||||||
use URI::QueryParam;
|
use URI::QueryParam;
|
||||||
|
use List::MoreUtils qw( uniq );
|
||||||
|
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use C4::Templates; # to get the template
|
use C4::Templates; # to get the template
|
||||||
|
@ -1209,15 +1210,18 @@ sub checkauth {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $br ( keys %$branches ) {
|
if ( C4::Context->preference('AutoLocation') && $auth_state ne 'failed' ) {
|
||||||
|
foreach my $br ( uniq( $branchcode, keys %$branches ) ) {
|
||||||
|
|
||||||
# now we work with the treatment of ip
|
# now we work with the treatment of ip
|
||||||
my $domain = $branches->{$br}->{'branchip'};
|
my $domain = $branches->{$br}->{'branchip'};
|
||||||
if ( $domain && $ip =~ /^$domain/ ) {
|
if ( $domain && $ip =~ /^$domain/ ) {
|
||||||
$branchcode = $branches->{$br}->{'branchcode'};
|
$branchcode = $branches->{$br}->{'branchcode'};
|
||||||
|
|
||||||
# new op dev : add the branchname to the cookie
|
# new op dev : add the branchname to the cookie
|
||||||
$branchname = $branches->{$br}->{'branchname'};
|
$branchname = $branches->{$br}->{'branchname'};
|
||||||
|
last;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue