Skip to content

Commit

Permalink
CUYAHOGA - Bug 36665: (follow-up) Allow choosing a branch with no IP …
Browse files Browse the repository at this point in the history
…when using AutoLocation

Signed-off-by: Jonathan Druart <[email protected]>
  • Loading branch information
kidclamp authored and kylemhall committed May 22, 2024
1 parent 8927269 commit 3d17fbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion C4/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1215,11 +1215,17 @@ sub checkauth {
}

if (
# If StaffLoginBranchBasedOnIP is enabled we will try to find a branch
# matching your ip, regardless of the choice you have passed in
(
!C4::Context->preference('AutoLocation')
&& C4::Context->preference('StaffLoginBranchBasedOnIP')
)
|| ( C4::Context->preference('AutoLocation') && $auth_state ne 'failed' )
# When AutoLocation is enabled we will not choose a branch matching IP
# if your selected branch has no IP set
|| ( C4::Context->preference('AutoLocation')
&& $auth_state ne 'failed'
&& $branches->{$branchcode}->{'branchip'} )
)
{
foreach my $br ( uniq( $branchcode, keys %$branches ) ) {
Expand Down
9 changes: 8 additions & 1 deletion t/db_dependent/Auth.t
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ subtest 'StaffLoginBranchBasedOnIP' => sub {

subtest 'AutoLocation' => sub {

plan tests => 7;
plan tests => 8;

$schema->storage->txn_begin;

Expand Down Expand Up @@ -1398,6 +1398,13 @@ subtest 'AutoLocation' => sub {
my $session = C4::Auth::get_session($sessionID);
is( $session->param('branch'), $patron->branchcode );

my $noip_library = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => '' } } );
$cgi->param( 'branch', $noip_library->branchcode );
( $userid, $cookie, $sessionID, $flags, $template ) =
C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' );
$session = C4::Auth::get_session($sessionID);
is( $session->param('branch'), $noip_library->branchcode );

$schema->storage->txn_rollback;

};
Expand Down

0 comments on commit 3d17fbe

Please sign in to comment.