Lines 1215-1257
sub checkauth {
Link Here
|
1215 |
$register_name = $register->name if ($register); |
1215 |
$register_name = $register->name if ($register); |
1216 |
} |
1216 |
} |
1217 |
my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search->as_list }; |
1217 |
my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search->as_list }; |
1218 |
if ( $type ne 'opac' and C4::Context->preference('AutoLocation') ) { |
1218 |
if ( $type ne 'opac' ) { |
1219 |
|
1219 |
if ( C4::Context->preference('AutoLocation') ) { |
1220 |
# we have to check they are coming from the right ip range |
1220 |
# we have to check they are coming from the right ip range |
1221 |
my $domain = $branches->{$branchcode}->{'branchip'}; |
1221 |
my $domain = $branches->{$branchcode}->{'branchip'}; |
1222 |
$domain =~ s|\.\*||g; |
1222 |
$domain =~ s|\.\*||g; |
1223 |
$domain =~ s/\s+//g; |
1223 |
$domain =~ s/\s+//g; |
1224 |
if ( $ip !~ /^$domain/ ) { |
1224 |
if ( $ip !~ /^$domain/ ) { |
1225 |
$cookie = $cookie_mgr->replace_in_list( $cookie, $query->cookie( |
1225 |
$cookie = $cookie_mgr->replace_in_list( $cookie, $query->cookie( |
1226 |
-name => 'CGISESSID', |
1226 |
-name => 'CGISESSID', |
1227 |
-value => '', |
1227 |
-value => '', |
1228 |
-HttpOnly => 1, |
1228 |
-HttpOnly => 1, |
1229 |
-secure => ( C4::Context->https_enabled() ? 1 : 0 ), |
1229 |
-secure => ( C4::Context->https_enabled() ? 1 : 0 ), |
1230 |
-sameSite => 'Lax', |
1230 |
-sameSite => 'Lax', |
1231 |
)); |
1231 |
)); |
1232 |
$info{'wrongip'} = 1; |
1232 |
$info{'wrongip'} = 1; |
1233 |
$auth_state = "failed"; |
1233 |
$auth_state = "failed"; |
|
|
1234 |
} |
1234 |
} |
1235 |
} |
1235 |
} |
|
|
1236 |
|
1237 |
if ( |
1238 |
( |
1239 |
!C4::Context->preference('AutoLocation') |
1240 |
&& C4::Context->preference('StaffLoginBranchBasedOnIP') |
1241 |
) |
1242 |
|| ( C4::Context->preference('AutoLocation') && $auth_state ne 'failed' ) |
1243 |
) |
1244 |
{ |
1245 |
foreach my $br ( uniq( $branchcode, keys %$branches ) ) { |
1246 |
|
1247 |
# now we work with the treatment of ip |
1248 |
my $domain = $branches->{$br}->{'branchip'}; |
1249 |
if ( $domain && $ip =~ /^$domain/ ) { |
1250 |
$branchcode = $branches->{$br}->{'branchcode'}; |
1251 |
|
1236 |
|
1252 |
# new op dev : add the branchname to the cookie |
1237 |
if ( |
1253 |
$branchname = $branches->{$br}->{'branchname'}; |
1238 |
( |
1254 |
last; |
1239 |
!C4::Context->preference('AutoLocation') |
|
|
1240 |
&& C4::Context->preference('StaffLoginBranchBasedOnIP') |
1241 |
) |
1242 |
|| ( C4::Context->preference('AutoLocation') && $auth_state ne 'failed' ) |
1243 |
) |
1244 |
{ |
1245 |
foreach my $br ( uniq( $branchcode, keys %$branches ) ) { |
1246 |
|
1247 |
# now we work with the treatment of ip |
1248 |
my $domain = $branches->{$br}->{'branchip'}; |
1249 |
if ( $domain && $ip =~ /^$domain/ ) { |
1250 |
$branchcode = $branches->{$br}->{'branchcode'}; |
1251 |
|
1252 |
# new op dev : add the branchname to the cookie |
1253 |
$branchname = $branches->{$br}->{'branchname'}; |
1254 |
last; |
1255 |
} |
1255 |
} |
1256 |
} |
1256 |
} |
1257 |
} |
1257 |
} |
1258 |
} |
1258 |
- |
|
|