From 5cfe50afb1cc19f16bc24cdb4aeae01f013c07c2 Mon Sep 17 00:00:00 2001 From: hdl Date: Wed, 5 Oct 2005 18:15:40 +0000 Subject: [PATCH] Fixing a bug in independant Branches management. --- C4/Auth.pm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index db851824fa..13fc198787 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -389,15 +389,20 @@ sub checkauth { } if ($return == 1){ my ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress); - my $sth=$dbh->prepare("select cardnumber,borrowernumber,userid,firstname,surname,flags,branchcode,emailaddress from borrowers where userid=?"); + my $sth=$dbh->prepare("select borrowernumber,firstname,surname,flags,branchcode,emailaddress from borrowers where userid=?"); $sth->execute($userid); - ($cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow; - warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; - unless ($cardnumber){ - my $sth=$dbh->prepare("select cardnumber,borrowernumber,userid,firstname,surname,flags,branchcode,emailaddress from borrowers where cardnumber=?"); + ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow if ($sth->rows); +# warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; + unless ($sth->rows){ + my $sth=$dbh->prepare("select borrowernumber,firstname,surname,flags,branchcode,emailaddress from borrowers where cardnumber=?"); $sth->execute($cardnumber); - ($cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow; - warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; + ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow if ($sth->rows); +# warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; + unless ($sth->rows){ + $sth->execute($userid); + ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow if ($sth->rows); + } +# warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; } my $hash = C4::Context::set_userenv( $bornum, @@ -409,7 +414,7 @@ sub checkauth { $userflags, $emailaddress, ); - warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; +# warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; $envcookie=$query->cookie(-name => 'userenv', -value => $hash, -expires => ''); -- 2.39.5