|
Lines 665-671
sub checkauth {
Link Here
|
| 665 |
C4::Context->_new_userenv($sessionID); |
665 |
C4::Context->_new_userenv($sessionID); |
| 666 |
my ($ip, $lasttime, $sessiontype); |
666 |
my ($ip, $lasttime, $sessiontype); |
| 667 |
if ($session){ |
667 |
if ($session){ |
| 668 |
C4::Context::set_userenv( |
668 |
C4::Context->set_userenv( |
| 669 |
$session->param('number'), $session->param('id'), |
669 |
$session->param('number'), $session->param('id'), |
| 670 |
$session->param('cardnumber'), $session->param('firstname'), |
670 |
$session->param('cardnumber'), $session->param('firstname'), |
| 671 |
$session->param('surname'), $session->param('branch'), |
671 |
$session->param('surname'), $session->param('branch'), |
|
Lines 938-944
sub checkauth {
Link Here
|
| 938 |
if ($persona){ |
938 |
if ($persona){ |
| 939 |
$session->param('persona',1); |
939 |
$session->param('persona',1); |
| 940 |
} |
940 |
} |
| 941 |
C4::Context::set_userenv( |
941 |
C4::Context->set_userenv( |
| 942 |
$session->param('number'), $session->param('id'), |
942 |
$session->param('number'), $session->param('id'), |
| 943 |
$session->param('cardnumber'), $session->param('firstname'), |
943 |
$session->param('cardnumber'), $session->param('firstname'), |
| 944 |
$session->param('surname'), $session->param('branch'), |
944 |
$session->param('surname'), $session->param('branch'), |
|
Lines 1169-1175
sub check_api_auth {
Link Here
|
| 1169 |
my $session = get_session($sessionID); |
1169 |
my $session = get_session($sessionID); |
| 1170 |
C4::Context->_new_userenv($sessionID); |
1170 |
C4::Context->_new_userenv($sessionID); |
| 1171 |
if ($session) { |
1171 |
if ($session) { |
| 1172 |
C4::Context::set_userenv( |
1172 |
C4::Context->set_userenv( |
| 1173 |
$session->param('number'), $session->param('id'), |
1173 |
$session->param('number'), $session->param('id'), |
| 1174 |
$session->param('cardnumber'), $session->param('firstname'), |
1174 |
$session->param('cardnumber'), $session->param('firstname'), |
| 1175 |
$session->param('surname'), $session->param('branch'), |
1175 |
$session->param('surname'), $session->param('branch'), |
|
Lines 1329-1335
sub check_api_auth {
Link Here
|
| 1329 |
$session->param('ip',$session->remote_addr()); |
1329 |
$session->param('ip',$session->remote_addr()); |
| 1330 |
$session->param('lasttime',time()); |
1330 |
$session->param('lasttime',time()); |
| 1331 |
} |
1331 |
} |
| 1332 |
C4::Context::set_userenv( |
1332 |
C4::Context->set_userenv( |
| 1333 |
$session->param('number'), $session->param('id'), |
1333 |
$session->param('number'), $session->param('id'), |
| 1334 |
$session->param('cardnumber'), $session->param('firstname'), |
1334 |
$session->param('cardnumber'), $session->param('firstname'), |
| 1335 |
$session->param('surname'), $session->param('branch'), |
1335 |
$session->param('surname'), $session->param('branch'), |
|
Lines 1408-1414
sub check_cookie_auth {
Link Here
|
| 1408 |
my $session = get_session($sessionID); |
1408 |
my $session = get_session($sessionID); |
| 1409 |
C4::Context->_new_userenv($sessionID); |
1409 |
C4::Context->_new_userenv($sessionID); |
| 1410 |
if ($session) { |
1410 |
if ($session) { |
| 1411 |
C4::Context::set_userenv( |
1411 |
C4::Context->set_userenv( |
| 1412 |
$session->param('number'), $session->param('id'), |
1412 |
$session->param('number'), $session->param('id'), |
| 1413 |
$session->param('cardnumber'), $session->param('firstname'), |
1413 |
$session->param('cardnumber'), $session->param('firstname'), |
| 1414 |
$session->param('surname'), $session->param('branch'), |
1414 |
$session->param('surname'), $session->param('branch'), |
|
Lines 1513-1547
sub checkpw_internal {
Link Here
|
| 1513 |
|
1513 |
|
| 1514 |
my $sth = |
1514 |
my $sth = |
| 1515 |
$dbh->prepare( |
1515 |
$dbh->prepare( |
| 1516 |
"select password,cardnumber,borrowernumber,userid,firstname,surname,branchcode,flags from borrowers where userid=?" |
1516 |
"select password,cardnumber,borrowernumber,userid,firstname,surname,borrowers.branchcode,branches.branchname,flags from borrowers join branches on borrowers.branchcode=branches.branchcode where userid=?" |
| 1517 |
); |
1517 |
); |
| 1518 |
$sth->execute($userid); |
1518 |
$sth->execute($userid); |
| 1519 |
if ( $sth->rows ) { |
1519 |
if ( $sth->rows ) { |
| 1520 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
1520 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
| 1521 |
$surname, $branchcode, $flags ) |
1521 |
$surname, $branchcode, $branchname, $flags ) |
| 1522 |
= $sth->fetchrow; |
1522 |
= $sth->fetchrow; |
| 1523 |
|
1523 |
|
| 1524 |
if ( checkpw_hash($password, $stored_hash) ) { |
1524 |
if ( checkpw_hash($password, $stored_hash) ) { |
| 1525 |
|
1525 |
|
| 1526 |
C4::Context->set_userenv( "$borrowernumber", $userid, $cardnumber, |
1526 |
C4::Context->set_userenv( "$borrowernumber", $userid, $cardnumber, |
| 1527 |
$firstname, $surname, $branchcode, $flags ); |
1527 |
$firstname, $surname, $branchcode, $branchname, $flags ); |
| 1528 |
return 1, $cardnumber, $userid; |
1528 |
return 1, $cardnumber, $userid; |
| 1529 |
} |
1529 |
} |
| 1530 |
} |
1530 |
} |
| 1531 |
$sth = |
1531 |
$sth = |
| 1532 |
$dbh->prepare( |
1532 |
$dbh->prepare( |
| 1533 |
"select password,cardnumber,borrowernumber,userid, firstname,surname,branchcode,flags from borrowers where cardnumber=?" |
1533 |
"select password,cardnumber,borrowernumber,userid,firstname,surname,borrowers.branchcode,branches.branchname,flags from borrowers join branches on borrowers.branchcode=branches.branchcode where cardnumber=?" |
| 1534 |
); |
1534 |
); |
| 1535 |
$sth->execute($userid); |
1535 |
$sth->execute($userid); |
| 1536 |
if ( $sth->rows ) { |
1536 |
if ( $sth->rows ) { |
| 1537 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
1537 |
my ( $stored_hash, $cardnumber, $borrowernumber, $userid, $firstname, |
| 1538 |
$surname, $branchcode, $flags ) |
1538 |
$surname, $branchcode, $branchname, $flags ) |
| 1539 |
= $sth->fetchrow; |
1539 |
= $sth->fetchrow; |
| 1540 |
|
1540 |
|
| 1541 |
if ( checkpw_hash($password, $stored_hash) ) { |
1541 |
if ( checkpw_hash($password, $stored_hash) ) { |
| 1542 |
|
1542 |
|
| 1543 |
C4::Context->set_userenv( $borrowernumber, $userid, $cardnumber, |
1543 |
C4::Context->set_userenv( $borrowernumber, $userid, $cardnumber, |
| 1544 |
$firstname, $surname, $branchcode, $flags ); |
1544 |
$firstname, $surname, $branchcode, $branchname, $flags ); |
| 1545 |
return 1, $cardnumber, $userid; |
1545 |
return 1, $cardnumber, $userid; |
| 1546 |
} |
1546 |
} |
| 1547 |
} |
1547 |
} |
|
Lines 1550-1556
sub checkpw_internal {
Link Here
|
| 1550 |
{ |
1550 |
{ |
| 1551 |
|
1551 |
|
| 1552 |
# Koha superuser account |
1552 |
# Koha superuser account |
| 1553 |
# C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"",1); |
1553 |
# C4::Context->set_userenv(0,0,C4::Context->config('user'),C4::Context->config('user'),C4::Context->config('user'),"","",1); |
| 1554 |
return 2; |
1554 |
return 2; |
| 1555 |
} |
1555 |
} |
| 1556 |
if ( $userid && $userid eq 'demo' |
1556 |
if ( $userid && $userid eq 'demo' |