From 8b862e36328413ac80155a448c1a51fe15180d24 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 2 Apr 2024 12:53:45 +0000 Subject: [PATCH] Bug 36483: Patrons.pm use case This case brought my attention as there was a different 'user' parameter being passed. It turns out we already thought about this, and `objects.to_api` is of course always passing it :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit 5d9396289e6ff754a79e5fad5f450144eb3a1c7c) Signed-off-by: Fridolin Somers --- Koha/REST/V1/Patrons.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm index 1318916671..cee539533a 100644 --- a/Koha/REST/V1/Patrons.pm +++ b/Koha/REST/V1/Patrons.pm @@ -103,8 +103,7 @@ Controller function that handles adding a new Koha::Patron object =cut sub add { - my $c = shift->openapi->valid_input or return; - my $current_user = $c->stash('koha.user'); + my $c = shift->openapi->valid_input or return; return try { @@ -169,7 +168,7 @@ sub add { $c->res->headers->location($c->req->url->to_string . '/' . $patron->borrowernumber); return $c->render( status => 201, - openapi => $patron->to_api( { user => $current_user } ) + openapi => $c->objects->to_api($patron), ); } ); @@ -261,8 +260,7 @@ Controller function that handles updating a Koha::Patron object =cut sub update { - my $c = shift->openapi->valid_input or return; - my $current_user = $c->stash('koha.user'); + my $c = shift->openapi->valid_input or return; my $patron = Koha::Patrons->find( $c->param('patron_id') ); @@ -311,7 +309,7 @@ sub update { $patron->discard_changes; return $c->render( status => 200, - openapi => $patron->to_api( { user => $current_user } ) + openapi => $c->objects->to_api($patron), ); } catch { -- 2.39.5