From 24896edf37c5d247ad2d788603300417db092374 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Tue, 19 Nov 2019 13:59:02 +0000 Subject: [PATCH] Bug 24067: Use owner_authorization in POST /public/patrons/{patron_id}/password As an example, use this functionality in Koha::REST::V1::Patrons::Password To test: 1. prove t/db_dependent/api/v1/patrons_password.t 2. Observe success Sponsored-by: Koha-Suomi Oy --- Koha/REST/V1/Patrons/Password.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Koha/REST/V1/Patrons/Password.pm b/Koha/REST/V1/Patrons/Password.pm index e9d42d7fcb..dab2afdf91 100644 --- a/Koha/REST/V1/Patrons/Password.pm +++ b/Koha/REST/V1/Patrons/Password.pm @@ -135,4 +135,15 @@ sub set_public { }; } +sub owner_authorization { + my ($c, $method, $user) = @_; + + if ($method eq 'set_public') { + my $patron_id = $c->match->stack->[-1]->{'patron_id'}; + return $user->borrowernumber == $patron_id ? 1 : 0; + } + + return 0; +} + 1; -- 2.17.1