diff --git a/lib/NGCP/Panel/Controller/API/CustomerContacts.pm b/lib/NGCP/Panel/Controller/API/CustomerContacts.pm
index e4bf20986b..951091f451 100644
--- a/lib/NGCP/Panel/Controller/API/CustomerContacts.pm
+++ b/lib/NGCP/Panel/Controller/API/CustomerContacts.pm
@@ -1,4 +1,4 @@
-package NGCP::Panel::Controller::API::CustomerContacts;
+ package NGCP::Panel::Controller::API::CustomerContacts;
use Sipwise::Base;
use namespace::sweep;
use boolean qw(true);
@@ -20,7 +20,7 @@ class_has 'api_description' => (
is => 'ro',
isa => 'Str',
default =>
- 'Defines a physical or legal person\'s address (postal and/or email) to be used to identify Customers.'
+ 'Defines a physical or legal person\'s address (postal and/or email) to be used to identify Customers.',
);
class_has 'query_params' => (
@@ -67,7 +67,7 @@ __PACKAGE__->config(
Does => [qw(ACL CheckTrailingSlash RequireSSL)],
Method => $_,
Path => __PACKAGE__->dispatch_path,
- } } @{ __PACKAGE__->allowed_methods }
+ } } @{ __PACKAGE__->allowed_methods },
},
action_roles => [qw(HTTPMethods)],
);
@@ -77,6 +77,7 @@ sub auto :Private {
$self->set_body($c);
$self->log_request($c);
+ return 1;
}
sub GET :Allow {
@@ -165,9 +166,17 @@ sub POST :Allow {
form => $form,
);
$resource->{country} = $resource->{country}{id};
+ my $reseller_id;
+ if($c->user->roles eq "admin") {
+ $reseller_id = $resource->{reseller_id};
+ } elsif($c->user->roles eq "reseller") {
+ $reseller_id = $c->user->reseller_id;
+ } else {
+ $reseller_id = $c->user->contract->contact->reseller_id;
+ }
my $reseller = $c->model('DB')->resultset('resellers')
- ->find($resource->{reseller_id});
+ ->find($reseller_id);
unless($reseller) {
$self->error($c, HTTP_UNPROCESSABLE_ENTITY, "Invalid 'reseller_id'");
last;
@@ -196,6 +205,7 @@ sub end : Private {
my ($self, $c) = @_;
$self->log_response($c);
+ return;
}
# vim: set tabstop=4 expandtab:
diff --git a/lib/NGCP/Panel/Controller/API/CustomerContactsItem.pm b/lib/NGCP/Panel/Controller/API/CustomerContactsItem.pm
index e90b3f9065..f5c3a4cf4b 100644
--- a/lib/NGCP/Panel/Controller/API/CustomerContactsItem.pm
+++ b/lib/NGCP/Panel/Controller/API/CustomerContactsItem.pm
@@ -28,7 +28,7 @@ __PACKAGE__->config(
Does => [qw(ACL RequireSSL)],
Method => $_,
Path => __PACKAGE__->dispatch_path,
- } } @{ __PACKAGE__->allowed_methods }
+ } } @{ __PACKAGE__->allowed_methods },
},
action_roles => [qw(HTTPMethods)],
);
@@ -38,6 +38,7 @@ sub auto :Private {
$self->set_body($c);
$self->log_request($c);
+ return 1;
}
sub GET :Allow {
@@ -52,9 +53,8 @@ sub GET :Allow {
# TODO: we don't need reseller stuff here!
my $response = HTTP::Response->new(HTTP_OK, undef, HTTP::Headers->new(
(map { # XXX Data::HAL must be able to generate links with multiple relations
- s|rel="(http://purl.org/sipwise/ngcp-api/#rel-resellers)"|rel="item $1"|;
- s/rel=self/rel="item self"/;
- $_
+ s|rel="(http://purl.org/sipwise/ngcp-api/#rel-resellers)"|rel="item $1"|r =~
+ s/rel=self/rel="item self"/r;
} $hal->http_headers),
), $hal->as_json);
$c->response->headers($response->headers);
@@ -194,6 +194,7 @@ sub end : Private {
my ($self, $c) = @_;
$self->log_response($c);
+ return;
}
# vim: set tabstop=4 expandtab: