From 5d52c8bf491acc9a0565b6db40d43fd54f79443b Mon Sep 17 00:00:00 2001 From: acli Date: Mon, 20 Jan 2003 07:38:23 +0000 Subject: [PATCH] Removed scoping-related perl warnings Factored similar code in getborrowernumber "i.e." in one comment should be "e.g." --- C4/Auth.pm | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index b70eb16cf9..02d547000b 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -320,26 +320,33 @@ sub checkauth { 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 +# 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 $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 $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')) { # Koha superuser account @@ -389,17 +396,14 @@ sub haspermission { sub getborrowernumber { 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) { + 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; } -- 2.39.5