Bug 28907: REST - Remove allow-owner from public checkouts route

To test:
1. prove t/db_dependent/api/v1/checkouts.t
2. Apply patch
3. prove t/db_dependent/api/v1/checkouts.t

Observe success in both cases.

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Lari Taskula 2024-09-18 08:44:46 +00:00 committed by Paul Derscheid
parent 24e08da733
commit 5d5bdf0415
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
3 changed files with 14 additions and 16 deletions

View File

@ -27,6 +27,7 @@ use Koha::Checkouts;
use Koha::Old::Checkouts;
use Koha::Token;
use Scalar::Util qw( blessed );
use Try::Tiny qw( catch try );
=head1 NAME
@ -191,18 +192,6 @@ sub add {
my $onsite = $body->{onsite_checkout};
my $barcode = $body->{external_id};
if ( $c->stash('is_public')
&& !C4::Context->preference('OpacTrustedCheckout') )
{
return $c->render(
status => 405,
openapi => {
error => 'Feature disabled',
error_code => 'FEATURE_DISABLED'
}
);
}
return try {
unless ( $item_id or $barcode ) {
@ -215,6 +204,18 @@ sub add {
);
}
if ( $c->stash('is_public') ) {
$c->auth->public($patron_id);
return $c->render(
status => 405,
openapi => {
error => 'Feature disabled',
error_code => 'FEATURE_DISABLED'
}
) if !C4::Context->preference('OpacTrustedCheckout');
}
my $item;
if ($item_id) {
$item = Koha::Items->find($item_id);

View File

@ -130,8 +130,6 @@
description: Under maintenance
schema:
$ref: "../swagger.yaml#/definitions/error"
x-koha-authorization:
allow-owner: true
"/public/patrons/{patron_id}/guarantors/can_see_charges":
put:
x-mojo-to: Patrons#guarantors_can_see_charges

View File

@ -554,8 +554,7 @@ subtest 'add checkout' => sub {
$t->post_ok( "//$userid:$password@/api/v1/public/patrons/$patron_id/checkouts" => json =>
{ item_id => $item1_id, patron_id => $patron_id } )->status_is(403)->json_is(
{
error => "Authorization failure. Missing required permission(s).",
required_permissions => undef
error => "Unprivileged user cannot access another user's resources"
}
);