TT#10837 Make allowed_roles array reference

Change-Id: I6ed557df160b963f964cd3cc09f79132ff37cfe8
changes/73/12873/22
Irina Peshinskaya 8 years ago
parent 10b25b2bba
commit 07b9f8dcae

@ -8,8 +8,8 @@ use NGCP::Panel::Utils::Admin;
__PACKAGE__->set_config();
sub allowed_roles {
return qw/admin reseller/;
sub config_allowed_roles {
return [qw/admin reseller/];
}
sub allowed_methods {

@ -109,12 +109,12 @@ sub GET :Allow {
my $module = $modules->[$i];
my $module_item = $module.'Item';
my $roles = $module->can('config') ? $module->config->{action}->{OPTIONS}->{AllowedRole}:[];
(!(ref $roles eq 'ARRAY')) and $roles = [$roles];
$roles = 'ARRAY' eq ref $roles ? $roles : [$roles];
$meta->{collections}->{$collection} = {
module => $module,
allowed_methods => $module->can('config') ? $module->config->{action} : {},
query_params => $module->can('query_params') ? [map {$_->{param}} @{$module->query_params}] : [],
allowed_roles => [$roles],
allowed_roles => $roles,
module_item => $module_item->can('config') ? $module_item : '',
allowed_methods_item => $module_item->can('config') ? $module_item->config->{action} : {},
#container_item_id => '',

@ -11,8 +11,8 @@ sub allowed_methods{
return [qw/OPTIONS HEAD GET POST/];
}
sub allowed_roles {
return qw/admin reseller subscriberadmin subscriber/;
sub config_allowed_roles {
return [qw/admin reseller subscriberadmin subscriber/];
}
sub api_description {

@ -10,8 +10,8 @@ sub allowed_methods{
return [qw/GET OPTIONS HEAD PUT DELETE/];
}
sub allowed_roles {
return qw/admin reseller subscriberadmin subscriber/;
sub config_allowed_roles {
return [qw/admin reseller subscriberadmin subscriber/];
}
sub _set_config{

@ -14,11 +14,13 @@ use NGCP::Panel::Utils::DataHalLink qw();
sub set_config {
my $self = shift;
my $allowed_roles = $self->config_allowed_roles;
$allowed_roles = 'ARRAY' eq ref $allowed_roles ? $allowed_roles : [$allowed_roles];
$self->config(
action => {
map { $_ => {
ACLDetachTo => '/api/root/invalid_user',
AllowedRole => [$self->allowed_roles],
AllowedRole => $allowed_roles,
Args => 0,
Does => [qw(ACL CheckTrailingSlash RequireSSL)],
Method => $_,
@ -37,8 +39,8 @@ sub gather_default_action_roles {
return @roles;
}
sub allowed_roles {
return qw/admin reseller/;
sub config_allowed_roles {
return [qw/admin reseller/];
}
sub get_list{

@ -18,11 +18,13 @@ use NGCP::Panel::Utils::ValidateJSON qw();
sub set_config {
my $self = shift;
my $allowed_roles = $self->config_allowed_roles;
$allowed_roles = 'ARRAY' eq ref $allowed_roles ? $allowed_roles : [$allowed_roles];
$self->config(
action => {
map { $_ => {
ACLDetachTo => '/api/root/invalid_user',
AllowedRole => [$self->allowed_roles],
AllowedRole => $allowed_roles,
Args => 1,
Does => [qw(ACL RequireSSL)],
Method => $_,
@ -41,8 +43,8 @@ sub gather_default_action_roles {
return @roles;
}
sub allowed_roles {
return qw/admin reseller/;
sub config_allowed_roles {
return [qw/admin reseller/];
}
sub get {

Loading…
Cancel
Save