TT#69503 - Change subscriber's domain assignation logic

* Only allow to assign domains for subscribers
	   from the same reseller as subscriber's customer

	 * Change Subscribers.yaml test to retrieve a
	   domain for testing from the same reseller
	   as subscriber's customer

Change-Id: I6c7cc7a9874207cfcd63360a6f87e2fd6841011c
changes/13/34713/2
Flaviu Mates 6 years ago
parent 54935452e8
commit a4265a91e0

@ -161,6 +161,12 @@ sub update_fields {
);
}
if($self->field('domain')) {
$self->field('domain')->field('id')->ajax_src(
$c->uri_for_action('/domain/ajax_filter_reseller', [$c->stash->{contract}->contact->reseller_id])->as_string
);
}
if($c->config->{security}->{password_sip_autogenerate}) {
$self->field('password')->inactive(1);
$self->field('password')->required(0);

@ -440,6 +440,11 @@ sub prepare_resource {
return;
}
if (!$customer->contact->reseller->domain_resellers->search({domain_id => $domain->id})->first()) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid 'domain', doesn't belong to the same reseller as subscriber's customer.");
return;
}
my $pilot;
if($customer->product->class eq 'pbxaccount') {
$pilot = $customer->voip_subscribers->search({

@ -22,7 +22,7 @@
name: get a domain for testing
type: item
method: GET
path: '/api/domains/?page=1&rows=1&order_by=id&order_by_direction=desc'
path: '/api/domains/?page=1&rows=1&order_by=id&order_by_direction=desc&reseller_id=1'
retain:
domain: body
perl_code: !!perl/code |

Loading…
Cancel
Save