From 7534ad4ebf00b771f0cf3a8ac9fbc63fc958d335 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 17 May 2023 19:56:43 +0100 Subject: [PATCH] Bug 30979: (follow-up) Fix public availability 500 When we introduced the logged in user id to the token generation we had the knock on effect of creating a 500 response for unauthenticated availability lookups. This patch resolves the 500, but results in a token that's not useful for the end user. We should consider this in the wider context down the line. Signed-off-by: Martin Renvoize --- Koha/REST/V1/Checkouts.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm index 42b9f4b4b6..b313edf83c 100644 --- a/Koha/REST/V1/Checkouts.pm +++ b/Koha/REST/V1/Checkouts.pm @@ -163,7 +163,7 @@ sub get_availability { $c->_check_availability( $patron, $item ); my $confirm_keys = join( ":", sort keys %{$confirmation} ); - $confirm_keys = $user->id . ":" . $item->id . ":" . $confirm_keys; + $confirm_keys = $user ? $user->id : '' . ":" . $item->id . ":" . $confirm_keys; my $token = Koha::Token->new->generate_jwt( { id => $confirm_keys } ); my $response = { -- 2.41.0