From d028948f1afc78579f9cd05584843e1a4d2b4616 Mon Sep 17 00:00:00 2001 From: Flaviu Mates Date: Tue, 25 Aug 2020 18:51:43 +0300 Subject: [PATCH] TT#90351 - Fix /api/subscribers PATCH * whenever webpassword was not PATCHed, the request would fail because the resource would have the encrypted webpassword from the DB and form valdiation would complai it's too long * the approach now is to remove the webpassword from resource before form validation if the resource has the same webpassword as the DB (i.e. webpassword wasn't (PATCHed) and then reassign it to the resource after form validation Change-Id: I86fab0f4bf789bd3518a74d49daf1a0402f20125 --- lib/NGCP/Panel/Utils/Subscriber.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/NGCP/Panel/Utils/Subscriber.pm b/lib/NGCP/Panel/Utils/Subscriber.pm index c5b1474fc4..435318116f 100644 --- a/lib/NGCP/Panel/Utils/Subscriber.pm +++ b/lib/NGCP/Panel/Utils/Subscriber.pm @@ -332,7 +332,14 @@ sub prepare_resource { } } + #if webpassword hasn't changed, it means that nothing has been done to it via PUT/PATCH, and it comes encrypted from the database + #so we're deleting it here for form's length validation and then reassigning it to the resource + my $webpassword; + $webpassword = delete $resource->{webpassword} if ( $resource->{webpassword} && $item && + $resource->{webpassword} eq $item->provisioning_voip_subscriber->webpassword ); return unless &$validate_code($resource); + $resource->{webpassword} = $webpassword if ($webpassword); + #my ($form) = $self->get_form($c); #return unless $self->validate_form( # c => $c,