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
(cherry picked from commit a7c45f170c)
mr12.5.1
Kirill Solomko 5 months ago
parent 8ca61f77ae
commit 923351a67e

@ -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/];
@ -42,7 +44,20 @@ sub query_params {
},
second => sub {},
},
}, ];
},
{
param => 'code',
description => 'Filter for a voucher with the base64 encoded code',
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,
});
},
},
],
}
use parent qw/NGCP::Panel::Role::Entities NGCP::Panel::Role::API::Vouchers/;

Loading…
Cancel
Save