TT#105100 fix PATCHing unset webpasswords

Change-Id: Ieb02d5ea4d8c1a8bee2ab94dfcf64778e79b8510
(cherry picked from commit 8325f3e5c5)
mr8.5.6
Rene Krenn 5 years ago
parent 4090aabef5
commit 50bdd7aae9

@ -332,18 +332,12 @@ 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 );
#password is mandatory field, so it cannot be absent from resource, the only reason for that being it was
#deleted in resource_from_item for admins without show_passwords flag; in this case, we are restoring it here
if (not length($resource->{password}) and $item and length($item->provisioning_voip_subscriber->password)) {
$resource->{password} = $item->provisioning_voip_subscriber->password;
if (length($resource->{webpassword}) and $item #and length($item->provisioning_voip_subscriber->webpassword)
and $resource->{webpassword} eq $item->provisioning_voip_subscriber->webpassword) {
$webpassword = delete $resource->{webpassword};
}
return unless &$validate_code($resource);
$resource->{webpassword} = $webpassword if ($webpassword);

Loading…
Cancel
Save