[Koha-cvs] CVS: koha/C4 Auth.pm,1.19,1.20

Ambrose Li acli at users.sourceforge.net
Mon Jan 20 08:38:26 CET 2003


Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv11322/C4

Modified Files:
	Auth.pm 
Log Message:
Removed scoping-related perl warnings
Factored similar code in getborrowernumber
"i.e." in one comment should be "e.g."


Index: Auth.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Auth.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** Auth.pm	19 Jan 2003 06:15:44 -0000	1.19
--- Auth.pm	20 Jan 2003 07:38:23 -0000	1.20
***************
*** 321,344 ****
  sub checkpw {
  
! # This should be modified to allow a select of authentication schemes (ie LDAP)
! # as well as local authentication through the borrowers tables passwd field
  #
  
      my ($dbh, $userid, $password) = @_;
!     my $sth=$dbh->prepare("select password,cardnumber from borrowers where userid=?");
!     $sth->execute($userid);
!     if ($sth->rows) {
  	my ($md5password,$cardnumber) = $sth->fetchrow;
  	if (md5_base64($password) eq $md5password) {
  	    return 1,$cardnumber;
  	}
      }
!     my $sth=$dbh->prepare("select password from borrowers where cardnumber=?");
!     $sth->execute($userid);
!     if ($sth->rows) {
  	my ($md5password) = $sth->fetchrow;
  	if (md5_base64($password) eq $md5password) {
  	    return 1,$userid;
  	}
      }
      if ($userid eq C4::Context->config('user') && $password eq C4::Context->config('pass')) {
--- 321,351 ----
  sub checkpw {
  
! # This should be modified to allow a selection of authentication schemes
! # (e.g. LDAP), as well as local authentication through the borrowers
! # tables passwd field
  #
  
      my ($dbh, $userid, $password) = @_;
!     {
!       my $sth=$dbh->prepare
! 	  ("select password,cardnumber from borrowers where userid=?");
!       $sth->execute($userid);
!       if ($sth->rows) {
  	my ($md5password,$cardnumber) = $sth->fetchrow;
  	if (md5_base64($password) eq $md5password) {
  	    return 1,$cardnumber;
  	}
+       }
      }
!     {
!       my $sth=$dbh->prepare
! 	  ("select password from borrowers where cardnumber=?");
!       $sth->execute($userid);
!       if ($sth->rows) {
  	my ($md5password) = $sth->fetchrow;
  	if (md5_base64($password) eq $md5password) {
  	    return 1,$userid;
  	}
+       }
      }
      if ($userid eq C4::Context->config('user') && $password eq C4::Context->config('pass')) {
***************
*** 390,404 ****
      my ($userid) = @_;
      my $dbh = C4::Context->dbh;
!     my $sth=$dbh->prepare("select borrowernumber from borrowers where userid=?");
!     $sth->execute($userid);
!     if ($sth->rows) {
! 	my ($bnumber) = $sth->fetchrow;
! 	return $bnumber;
!     }
!     my $sth=$dbh->prepare("select borrowernumber from borrowers where cardnumber=?");
!     $sth->execute($userid);
!     if ($sth->rows) {
  	my ($bnumber) = $sth->fetchrow;
  	return $bnumber;
      }
      return 0;
--- 397,408 ----
      my ($userid) = @_;
      my $dbh = C4::Context->dbh;
!     for my $field ('userid', 'cardnumber') {
!       my $sth=$dbh->prepare
! 	  ("select borrowernumber from borrowers where $field=?");
!       $sth->execute($userid);
!       if ($sth->rows) {
  	my ($bnumber) = $sth->fetchrow;
  	return $bnumber;
+       }
      }
      return 0;





More information about the Koha-cvs mailing list