@@ -, +, @@ branchip: 172.18.0.1 branchip: 172.18.0.1 branchip: 172.18.0.4 --- C4/Auth.pm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -26,6 +26,7 @@ use CGI::Session; use CGI::Session::ErrorHandler; use URI; use URI::QueryParam; +use List::MoreUtils qw( uniq ); use C4::Context; use C4::Templates; # to get the template @@ -1213,15 +1214,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 - my $domain = $branches->{$br}->{'branchip'}; - if ( $domain && $ip =~ /^$domain/ ) { - $branchcode = $branches->{$br}->{'branchcode'}; + # now we work with the treatment of ip + my $domain = $branches->{$br}->{'branchip'}; + if ( $domain && $ip =~ /^$domain/ ) { + $branchcode = $branches->{$br}->{'branchcode'}; - # new op dev : add the branchname to the cookie - $branchname = $branches->{$br}->{'branchname'}; + # new op dev : add the branchname to the cookie + $branchname = $branches->{$br}->{'branchname'}; + last; + } } } --