| 
      
            Lines 1048-1057
          sub checkauth {
      
      
        Link Here
      
     | 
  
        
          | 1048 | 
                          }  | 
          1048 | 
                          }  | 
        
        
          | 1049 | 
                      }  | 
          1049 | 
                      }  | 
        
        
          | 1050 | 
           | 
          1050 | 
           | 
        
          
            
              | 1051 | 
                          # $return: 1 = valid user, 2 = superlibrarian  | 
              1051 | 
                          # $return: 1 = valid user  | 
            
        
          | 1052 | 
                      if ($return) { | 
          1052 | 
                      if ($return) { | 
        
            
              | 1053 | 
                              # If DB user is logged in  | 
               | 
               | 
            
            
              | 1054 | 
                              $userid ||= $q_userid if $return == 2;  | 
            
        
          | 1055 | 
           | 
          1053 | 
           | 
        
        
          | 1056 | 
                          #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime)); | 
          1054 | 
                          #_session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime)); | 
        
        
          | 1057 | 
                          if ( $flags = haspermission( $userid, $flagsrequired ) ) { | 
          1055 | 
                          if ( $flags = haspermission( $userid, $flagsrequired ) ) { | 
        
  
    | 
      
            Lines 1151-1172
          sub checkauth {
      
      
        Link Here
      
     | 
  
        
          | 1151 | 
                              $session->param( 'shibboleth',   $shibSuccess );  | 
          1149 | 
                              $session->param( 'shibboleth',   $shibSuccess );  | 
        
        
          | 1152 | 
                              $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch); | 
          1150 | 
                              $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map { $session->param($_) } qw(cardnumber firstname surname branch); | 
        
        
          | 1153 | 
                          }  | 
          1151 | 
                          }  | 
        
            
              | 1154 | 
                              elsif ( $return == 2 ) { | 
               | 
               | 
            
            
              | 1155 | 
               | 
            
            
              | 1156 | 
                                  #We suppose the user is the superlibrarian  | 
            
            
              | 1157 | 
                                  $borrowernumber = 0;  | 
            
            
              | 1158 | 
                                  $session->param( 'number',       0 );  | 
            
            
              | 1159 | 
                                  $session->param( 'id',           C4::Context->config('user') ); | 
            
            
              | 1160 | 
                                  $session->param( 'cardnumber',   C4::Context->config('user') ); | 
            
            
              | 1161 | 
                                  $session->param( 'firstname',    C4::Context->config('user') ); | 
            
            
              | 1162 | 
                                  $session->param( 'surname',      C4::Context->config('user') ); | 
            
            
              | 1163 | 
                                  $session->param( 'branch',       'NO_LIBRARY_SET' );  | 
            
            
              | 1164 | 
                                  $session->param( 'branchname',   'NO_LIBRARY_SET' );  | 
            
            
              | 1165 | 
                                  $session->param( 'flags',        1 );  | 
            
            
              | 1166 | 
                                  $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') ); | 
            
            
              | 1167 | 
                                  $session->param( 'ip',           $session->remote_addr() );  | 
            
            
              | 1168 | 
                                  $session->param( 'lasttime',     time() );  | 
            
            
              | 1169 | 
                              }  | 
            
        
          | 1170 | 
                          $session->param('cas_ticket', $cas_ticket) if $cas_ticket; | 
          1152 | 
                          $session->param('cas_ticket', $cas_ticket) if $cas_ticket; | 
        
        
          | 1171 | 
                          C4::Context->set_userenv(  | 
          1153 | 
                          C4::Context->set_userenv(  | 
        
        
          | 1172 | 
                              $session->param('number'),       $session->param('id'), | 
          1154 | 
                              $session->param('number'),       $session->param('id'), | 
        
  
    | 
      
            Lines 1598-1617
          sub check_api_auth {
      
      
        Link Here
      
     | 
  
        
          | 1598 | 
                          $session->param( 'emailaddress', $emailaddress );  | 
          1580 | 
                          $session->param( 'emailaddress', $emailaddress );  | 
        
        
          | 1599 | 
                          $session->param( 'ip',           $session->remote_addr() );  | 
          1581 | 
                          $session->param( 'ip',           $session->remote_addr() );  | 
        
        
          | 1600 | 
                          $session->param( 'lasttime',     time() );  | 
          1582 | 
                          $session->param( 'lasttime',     time() );  | 
        
            
              | 1601 | 
                          } elsif ( $return == 2 ) { | 
               | 
               | 
            
            
              | 1602 | 
               | 
            
            
              | 1603 | 
                              #We suppose the user is the superlibrarian  | 
            
            
              | 1604 | 
                              $session->param( 'number',       0 );  | 
            
            
              | 1605 | 
                              $session->param( 'id',           C4::Context->config('user') ); | 
            
            
              | 1606 | 
                              $session->param( 'cardnumber',   C4::Context->config('user') ); | 
            
            
              | 1607 | 
                              $session->param( 'firstname',    C4::Context->config('user') ); | 
            
            
              | 1608 | 
                              $session->param( 'surname',      C4::Context->config('user') ); | 
            
            
              | 1609 | 
                              $session->param( 'branch',       'NO_LIBRARY_SET' );  | 
            
            
              | 1610 | 
                              $session->param( 'branchname',   'NO_LIBRARY_SET' );  | 
            
            
              | 1611 | 
                              $session->param( 'flags',        1 );  | 
            
            
              | 1612 | 
                              $session->param( 'emailaddress', C4::Context->preference('KohaAdminEmailAddress') ); | 
            
            
              | 1613 | 
                              $session->param( 'ip',           $session->remote_addr() );  | 
            
            
              | 1614 | 
                              $session->param( 'lasttime',     time() );  | 
            
        
          | 1615 | 
                      }  | 
          1583 | 
                      }  | 
        
        
          | 1616 | 
                      $session->param( 'cas_ticket', $cas_ticket);  | 
          1584 | 
                      $session->param( 'cas_ticket', $cas_ticket);  | 
        
        
          | 1617 | 
                      C4::Context->set_userenv(  | 
          1585 | 
                      C4::Context->set_userenv(  | 
        
  
    | 
      
            Lines 1805-1811
          sub checkpw {
      
      
        Link Here
      
     | 
  
        
          | 1805 | 
              # 1 if auth is ok  | 
          1773 | 
              # 1 if auth is ok  | 
        
        
          | 1806 | 
              # 0 if auth is nok  | 
          1774 | 
              # 0 if auth is nok  | 
        
        
          | 1807 | 
              # -1 if user bind failed (LDAP only)  | 
          1775 | 
              # -1 if user bind failed (LDAP only)  | 
        
            
              | 1808 | 
                  # 2 if DB user is used (internal only)  | 
               | 
               | 
            
        
          | 1809 | 
           | 
          1776 | 
           | 
        
        
          | 1810 | 
              if ( $patron and $patron->account_locked ) { | 
          1777 | 
              if ( $patron and $patron->account_locked ) { | 
        
        
          | 1811 | 
                  # Nothing to check, account is locked  | 
          1778 | 
                  # Nothing to check, account is locked  | 
        
  
    | 
      
            Lines 1878-1895
          sub checkpw_internal {
      
      
        Link Here
      
     | 
  
        
          | 1878 | 
              $password = Encode::encode( 'UTF-8', $password )  | 
          1845 | 
              $password = Encode::encode( 'UTF-8', $password )  | 
        
        
          | 1879 | 
                if Encode::is_utf8($password);  | 
          1846 | 
                if Encode::is_utf8($password);  | 
        
        
          | 1880 | 
           | 
          1847 | 
           | 
        
            
              | 1881 | 
                  if ( $userid && $userid eq C4::Context->config('user') ) { | 
               | 
               | 
            
            
              | 1882 | 
                      if ( $password && $password eq C4::Context->config('pass') ) { | 
            
            
              | 1883 | 
               | 
            
            
              | 1884 | 
                          # Koha superuser account  | 
            
            
              | 1885 | 
                          #     C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"",1); | 
            
            
              | 1886 | 
                          return 2;  | 
            
            
              | 1887 | 
                      }  | 
            
            
              | 1888 | 
                      else { | 
            
            
              | 1889 | 
                          return 0;  | 
            
            
              | 1890 | 
                      }  | 
            
            
              | 1891 | 
                  }  | 
            
            
              | 1892 | 
               | 
            
        
          | 1893 | 
              my $sth =  | 
          1848 | 
              my $sth =  | 
        
        
          | 1894 | 
                $dbh->prepare(  | 
          1849 | 
                $dbh->prepare(  | 
        
        
          | 1895 | 
                  "select password,cardnumber,borrowernumber,userid,firstname,surname,borrowers.branchcode,branches.branchname,flags from borrowers join branches on borrowers.branchcode=branches.branchcode where userid=?"  | 
          1850 | 
                  "select password,cardnumber,borrowernumber,userid,firstname,surname,borrowers.branchcode,branches.branchname,flags from borrowers join branches on borrowers.branchcode=branches.branchcode where userid=?"  |