X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FAuth.pm;h=c392e44998f17fcfb170d5479117afb1ba8b128c;hb=cf459b6ddd775b8ac2b0097fb88b547af8ae9f30;hp=77eb4428e49d3ed815d2f62aa5dfccfc3ef1c423;hpb=4afc512039b08981152e62a6f7f3f4f35482a066;p=koha.git diff --git a/C4/Auth.pm b/C4/Auth.pm index 77eb4428e4..c392e44998 100755 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -211,7 +211,7 @@ sub get_template_and_user { } if ( $flags && $flags->{updatecharges} == 1 ) { - $template->param( CAN_user_updatecharge => 1 ); + $template->param( CAN_user_updatecharges => 1 ); } if ( $flags && $flags->{acquisition} == 1 ) { @@ -456,7 +456,7 @@ sub checkauth { ); $loggedin = 1; } - elsif ( $sessionID = $query->cookie("CGISESSID")) { # assignment, not comparison (?) + elsif ( $sessionID = $query->cookie("CGISESSID")) { # assignment, not comparison my $session = get_session($sessionID); C4::Context->_new_userenv($sessionID); if ($session){ @@ -535,7 +535,7 @@ sub checkauth { _session_log(sprintf "%20s from %16s logged in at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},localtime); $cookie = $query->cookie(CGISESSID => $sessionID); if ( $flags = haspermission( $dbh, $userid, $flagsrequired ) ) { - $loggedin = 1; + $loggedin = 1; } else { $info{'nopermission'} = 1; @@ -590,6 +590,15 @@ sub checkauth { $branchname = GetBranchName($branchcode); } my $branches = GetBranches(); + if (C4::Context->boolean_preference('IndependantBranches') && C4::Context->boolean_preference('Autolocation')){ + # we have to check they are coming from the right ip range + my $domain = $branches->{$branchcode}->{'branchip'}; + if ($ip !~ /^$domain/){ + $loggedin=0; + $info{'wrongip'} = 1; + } + } + my @branchesloop; foreach my $br ( keys %$branches ) { # now we work with the treatment of ip @@ -644,6 +653,7 @@ sub checkauth { $info{'invalid_username_or_password'} = 1; C4::Context->_unset_userenv($sessionID); } + } } my $insecure = C4::Context->boolean_preference('insecure'); @@ -706,7 +716,9 @@ sub checkauth { IndependantBranches => C4::Context->preference("IndependantBranches"), AutoLocation => C4::Context->preference("AutoLocation"), yuipath => C4::Context->preference("yuipath"), + wrongip => $info{'wrongip'} ); + $template->param( loginprompt => 1 ) unless $info{'nopermission'}; my $self_url = $query->url( -absolute => 1 );