Bug 40943: Use session_id from userenv instead of cookie for value_builder

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
[EDIT] Inline tidy. Moved set_userenv_from_session before POD of next sub.
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2024-09-24 15:22:59 +02:00 committed by Lucas Gass
parent b34d5194f5
commit 01514e3aa4
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
10 changed files with 39 additions and 24 deletions

View File

@ -666,6 +666,20 @@ sub userenv {
return $context->{userenv};
}
sub set_userenv_from_session {
my ( $class, $session ) = @_;
return $class->set_userenv(
$session->param('number'), $session->param('id') // '',
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('shibboleth'),
$session->param('desk_id'), $session->param('desk_name'),
$session->param('register_id'), $session->param('register_name'),
$session->id,
);
}
=head2 set_userenv
C4::Context->set_userenv($usernum, $userid, $usercnum,
@ -685,10 +699,10 @@ set_userenv is called in Auth.pm
sub set_userenv {
shift @_;
my (
$usernum, $userid, $usercnum, $userfirstname,
$usersurname, $userbranch, $branchname, $userflags,
$emailaddress, $shibboleth, $desk_id, $desk_name,
$register_id, $register_name
$usernum, $userid, $usercnum, $userfirstname,
$usersurname, $userbranch, $branchname, $userflags,
$emailaddress, $shibboleth, $desk_id, $desk_name,
$register_id, $register_name, $session_id,
) = @_;
my $cell = {
@ -707,7 +721,8 @@ sub set_userenv {
"desk_id" => $desk_id,
"desk_name" => $desk_name,
"register_id" => $register_id,
"register_name" => $register_name
"register_name" => $register_name,
"session_id" => $session_id,
};
$context->{userenv} = $cell;
return $cell;

View File

@ -254,17 +254,7 @@ sub checkauth {
if ($session) {
if ( $session->param('cardnumber') ) {
C4::Context->set_userenv(
$session->param('number'),
$session->param('id'),
$session->param('cardnumber'),
$session->param('firstname'),
$session->param('surname'),
$session->param('branch'),
$session->param('branchname'),
$session->param('flags'),
$session->param('emailaddress')
);
C4::Context->set_userenv_from_session($session);
$cookie = $query->cookie(
-name => 'CGISESSID',
-value => $session->id,

View File

@ -31,7 +31,7 @@ use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -23,9 +23,11 @@
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
use C4::Context;
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -23,9 +23,11 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
use C4::Context;
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -23,9 +23,11 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
use C4::Context;
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -29,9 +29,11 @@ use C4::Context;
use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
use C4::Context;
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -26,9 +26,10 @@ use C4::Context;
use Koha::Libraries;
use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -25,7 +25,7 @@ use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;

View File

@ -32,9 +32,10 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( check_cookie_auth );
use C4::Context;
my $input = CGI->new;
my ($auth_status) =
check_cookie_auth( $input->cookie('CGISESSID'), { catalogue => 1 } );
check_cookie_auth( C4::Context->userenv->{session_id}, { catalogue => 1 } );
if ( $auth_status ne "ok" ) {
print $input->header( -type => 'text/plain', -status => '403 Forbidden' );
exit 0;