From 927be2a7577b17b344ed3daba0647c6114bb266a Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Thu, 7 Aug 2025 14:03:04 +0200 Subject: [PATCH] MT#63320 fix /api/vouchers search by code * base64 code provided in the query params is now correctly re-encoded as encrypted base64 string to use in search. Change-Id: Id9e45079b260bdc51465a781124f6fbb636cf2db --- lib/NGCP/Panel/Controller/API/Vouchers.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/Panel/Controller/API/Vouchers.pm b/lib/NGCP/Panel/Controller/API/Vouchers.pm index 2485dcbf98..7cbb03f0bd 100644 --- a/lib/NGCP/Panel/Controller/API/Vouchers.pm +++ b/lib/NGCP/Panel/Controller/API/Vouchers.pm @@ -8,8 +8,10 @@ use Data::HAL qw(); use Data::HAL::Link qw(); use HTTP::Headers qw(); use HTTP::Status qw(:constants); +use MIME::Base64; use NGCP::Panel::Utils::DateTime; +use NGCP::Panel::Utils::Voucher; sub allowed_methods{ return [qw/GET POST OPTIONS HEAD/]; @@ -46,7 +48,14 @@ sub query_params { { param => 'code', description => 'Filter for a voucher with the base64 encoded code', - query_type => 'string_eq', + new_rs => sub { + my ($c,$q,$rs) = @_; + my $code = decode_base64($q); + my $enc_code = NGCP::Panel::Utils::Voucher::encrypt_code($c, $code); + return $rs->search_rs({ + code => $enc_code, + }); + }, }, ], }