Lines 670-676
sub checkauth {
Link Here
|
670 |
C4::Context->_new_userenv($sessionID); |
670 |
C4::Context->_new_userenv($sessionID); |
671 |
my ($ip, $lasttime, $sessiontype); |
671 |
my ($ip, $lasttime, $sessiontype); |
672 |
if ($session){ |
672 |
if ($session){ |
673 |
C4::Context::set_userenv( |
673 |
C4::Context->set_userenv( |
674 |
$session->param('number'), $session->param('id'), |
674 |
$session->param('number'), $session->param('id'), |
675 |
$session->param('cardnumber'), $session->param('firstname'), |
675 |
$session->param('cardnumber'), $session->param('firstname'), |
676 |
$session->param('surname'), $session->param('branch'), |
676 |
$session->param('surname'), $session->param('branch'), |
Lines 943-949
sub checkauth {
Link Here
|
943 |
if ($persona){ |
943 |
if ($persona){ |
944 |
$session->param('persona',1); |
944 |
$session->param('persona',1); |
945 |
} |
945 |
} |
946 |
C4::Context::set_userenv( |
946 |
C4::Context->set_userenv( |
947 |
$session->param('number'), $session->param('id'), |
947 |
$session->param('number'), $session->param('id'), |
948 |
$session->param('cardnumber'), $session->param('firstname'), |
948 |
$session->param('cardnumber'), $session->param('firstname'), |
949 |
$session->param('surname'), $session->param('branch'), |
949 |
$session->param('surname'), $session->param('branch'), |
Lines 1174-1180
sub check_api_auth {
Link Here
|
1174 |
my $session = get_session($sessionID); |
1174 |
my $session = get_session($sessionID); |
1175 |
C4::Context->_new_userenv($sessionID); |
1175 |
C4::Context->_new_userenv($sessionID); |
1176 |
if ($session) { |
1176 |
if ($session) { |
1177 |
C4::Context::set_userenv( |
1177 |
C4::Context->set_userenv( |
1178 |
$session->param('number'), $session->param('id'), |
1178 |
$session->param('number'), $session->param('id'), |
1179 |
$session->param('cardnumber'), $session->param('firstname'), |
1179 |
$session->param('cardnumber'), $session->param('firstname'), |
1180 |
$session->param('surname'), $session->param('branch'), |
1180 |
$session->param('surname'), $session->param('branch'), |
Lines 1334-1340
sub check_api_auth {
Link Here
|
1334 |
$session->param('ip',$session->remote_addr()); |
1334 |
$session->param('ip',$session->remote_addr()); |
1335 |
$session->param('lasttime',time()); |
1335 |
$session->param('lasttime',time()); |
1336 |
} |
1336 |
} |
1337 |
C4::Context::set_userenv( |
1337 |
C4::Context->set_userenv( |
1338 |
$session->param('number'), $session->param('id'), |
1338 |
$session->param('number'), $session->param('id'), |
1339 |
$session->param('cardnumber'), $session->param('firstname'), |
1339 |
$session->param('cardnumber'), $session->param('firstname'), |
1340 |
$session->param('surname'), $session->param('branch'), |
1340 |
$session->param('surname'), $session->param('branch'), |
Lines 1413-1419
sub check_cookie_auth {
Link Here
|
1413 |
my $session = get_session($sessionID); |
1413 |
my $session = get_session($sessionID); |
1414 |
C4::Context->_new_userenv($sessionID); |
1414 |
C4::Context->_new_userenv($sessionID); |
1415 |
if ($session) { |
1415 |
if ($session) { |
1416 |
C4::Context::set_userenv( |
1416 |
C4::Context->set_userenv( |
1417 |
$session->param('number'), $session->param('id'), |
1417 |
$session->param('number'), $session->param('id'), |
1418 |
$session->param('cardnumber'), $session->param('firstname'), |
1418 |
$session->param('cardnumber'), $session->param('firstname'), |
1419 |
$session->param('surname'), $session->param('branch'), |
1419 |
$session->param('surname'), $session->param('branch'), |
Lines 1518-1552
sub checkpw_internal {
Link Here
|
1518 |
|
1518 |
|
1519 |
my $sth = |
1519 |
my $sth = |
1520 |
$dbh->prepare( |
1520 |
$dbh->prepare( |
1521 |
"select password,cardnumber,borrowernumber,userid,firstname,surname,branchcode,flags from borrowers where userid=?" |
1521 |
"select password,cardnumber,borrowernumber,userid,firstname,surname,borrowers.branchcode,branches.branchname,flags from borrowers join branches on borrowers.branchcode=branches.branchcode where userid=?" |
1522 |
); |
1522 |
); |
1523 |
$sth->execute($userid); |
1523 |
$sth->execute($userid); |
1524 |
if ( $sth->rows ) { |
1524 |
if ( $sth->rows ) { |
1525 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
1525 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
1526 |
$surname, $branchcode, $flags ) |
1526 |
$surname, $branchcode, $branchname, $flags ) |
1527 |
= $sth->fetchrow; |
1527 |
= $sth->fetchrow; |
1528 |
|
1528 |
|
1529 |
if ( checkpw_hash($password, $stored_hash) ) { |
1529 |
if ( checkpw_hash($password, $stored_hash) ) { |
1530 |
|
1530 |
|
1531 |
C4::Context->set_userenv( "$borrowernumber", $userid, $cardnumber, |
1531 |
C4::Context->set_userenv( "$borrowernumber", $userid, $cardnumber, |
1532 |
$firstname, $surname, $branchcode, $flags ); |
1532 |
$firstname, $surname, $branchcode, $branchname, $flags ); |
1533 |
return 1, $cardnumber, $userid; |
1533 |
return 1, $cardnumber, $userid; |
1534 |
} |
1534 |
} |
1535 |
} |
1535 |
} |
1536 |
$sth = |
1536 |
$sth = |
1537 |
$dbh->prepare( |
1537 |
$dbh->prepare( |
1538 |
"select password,cardnumber,borrowernumber,userid, firstname,surname,branchcode,flags from borrowers where cardnumber=?" |
1538 |
"select password,cardnumber,borrowernumber,userid,firstname,surname,borrowers.branchcode,branches.branchname,flags from borrowers join branches on borrowers.branchcode=branches.branchcode where cardnumber=?" |
1539 |
); |
1539 |
); |
1540 |
$sth->execute($userid); |
1540 |
$sth->execute($userid); |
1541 |
if ( $sth->rows ) { |
1541 |
if ( $sth->rows ) { |
1542 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
1542 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
1543 |
$surname, $branchcode, $flags ) |
1543 |
$surname, $branchcode, $branchname, $flags ) |
1544 |
= $sth->fetchrow; |
1544 |
= $sth->fetchrow; |
1545 |
|
1545 |
|
1546 |
if ( checkpw_hash($password, $stored_hash) ) { |
1546 |
if ( checkpw_hash($password, $stored_hash) ) { |
1547 |
|
1547 |
|
1548 |
C4::Context->set_userenv( $borrowernumber, $userid, $cardnumber, |
1548 |
C4::Context->set_userenv( $borrowernumber, $userid, $cardnumber, |
1549 |
$firstname, $surname, $branchcode, $flags ); |
1549 |
$firstname, $surname, $branchcode, $branchname, $flags ); |
1550 |
return 1, $cardnumber, $userid; |
1550 |
return 1, $cardnumber, $userid; |
1551 |
} |
1551 |
} |
1552 |
} |
1552 |
} |
Lines 1555-1561
sub checkpw_internal {
Link Here
|
1555 |
{ |
1555 |
{ |
1556 |
|
1556 |
|
1557 |
# Koha superuser account |
1557 |
# Koha superuser account |
1558 |
# C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"",1); |
1558 |
# C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"","",1); |
1559 |
return 2; |
1559 |
return 2; |
1560 |
} |
1560 |
} |
1561 |
if ( $userid && $userid eq 'demo' |
1561 |
if ( $userid && $userid eq 'demo' |