From fdd7731a46901a9c340953e57cec1c53a8fb1f40 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 12 Mar 2024 14:14:27 +0100 Subject: [PATCH] Revert "Bug 34755: Backport Koha::Token change from bug 34478" This reverts commit 46c0419a11d56b078f1f8528e51bf1a78bd284e6. --- Koha/Token.pm | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Koha/Token.pm b/Koha/Token.pm index 2c0817a26d..c4d23aeada 100644 --- a/Koha/Token.pm +++ b/Koha/Token.pm @@ -57,8 +57,6 @@ use Digest::MD5 qw( md5_base64 ); use Encode; use C4::Context; use Koha::Exceptions::Token; -use Koha::Session; - use base qw(Class::Accessor); use constant HMAC_SHA1_LENGTH => 20; use constant CSRF_EXPIRY_HOURS => 8; # 8 hours instead of 7 days.. @@ -217,17 +215,11 @@ sub decode_jwt { sub _add_default_csrf_params { my ( $params ) = @_; $params->{session_id} //= DEFA_SESSION_ID; - - my $id; - my $session = Koha::Session->get_session( { sessionID => $params->{session_id} } ); - if ($session) { - $id = $session->param('id'); + my $userenv = C4::Context->userenv; + if ( ( !$userenv ) || !$userenv->{id} ) { + $userenv = { id => DEFA_SESSION_USERID }; } - if ( !$id ) { - $id = DEFA_SESSION_USERID; - } - - $params->{id} //= Encode::encode( 'UTF-8', $id ); + $params->{id} //= Encode::encode( 'UTF-8', $userenv->{id} ); $params->{id} .= '_' . $params->{session_id}; my $pw = C4::Context->config('pass'); -- 2.39.5