From 9a1f4917e99262a7fab7209b1d2c7b9fc3ff222b Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Apr 2019 15:56:44 -0300 Subject: [PATCH] [UGLY FIX] Bug 18205: Set userenv in Koha::REST::V1::Auth::authenticate_api_request Koha code (like C4::Log::logaction) relies on C4::Context::userenv to be set. This could be fixed in many ways. The easiest way is to set that environmental variables after authorization happens. I don't think this is a good design, but I'm not sure adding a new param to logaction is the best option. I'd rather make the action_logs table another target for Log4Perl at some point. But I strongly disagree on making tiny enhancements be required to refactor all the things :-D I drop this code here for others to weight in. Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/Auth.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm index 53c6bacfc9..58d8f54e25 100644 --- a/Koha/REST/V1/Auth.pm +++ b/Koha/REST/V1/Auth.pm @@ -219,6 +219,8 @@ sub authenticate_api_request { } $c->stash('koha.user' => $user); + C4::Context->_new_userenv( 1 ); + C4::Context->set_userenv( $user->borrowernumber, $user->userid ); # We do not need any authorization unless ($authorization) { -- 2.21.0