Tenant resource tenancy check - style change

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c72dda5f
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c72dda5f
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c72dda5f

Branch: refs/heads/master
Commit: c72dda5f1678dda6402dd53566cc6679688cfa80
Parents: 0fffefe
Author: nir-sopher <n...@qwilt.com>
Authored: Wed Jun 21 05:34:26 2017 +0300
Committer: Jeremy Mitchell <mitchell...@gmail.com>
Committed: Tue Jul 18 12:12:32 2017 -0600

----------------------------------------------------------------------
 traffic_ops/app/lib/API/Tenant.pm | 49 +++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c72dda5f/traffic_ops/app/lib/API/Tenant.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/API/Tenant.pm 
b/traffic_ops/app/lib/API/Tenant.pm
index 1c226b3..3653455 100644
--- a/traffic_ops/app/lib/API/Tenant.pm
+++ b/traffic_ops/app/lib/API/Tenant.pm
@@ -42,17 +42,18 @@ sub index {
        my @data = ();
        my @tenants_list = 
$tenant_utils->get_hierarchic_tenants_list($tenants_data, undef);
        foreach my $row (@tenants_list) {
-               if ($tenant_utils->is_tenant_resource_accessible($tenants_data, 
$row->id)) {
-                       push(
-                               @data, {
-                                       "id"             => $row->id,
-                                       "name"           => $row->name,
-                                       "active"         => \$row->active,
-                                       "parentId"       => $row->parent_id,
-                                       "parentName"     => ( defined 
$row->parent_id ) ? $tenant_utils->get_tenant_by_id($tenants_data, 
$row->parent_id)->name : undef,
-                               }
-                       );
-               }
+               if 
(!$tenant_utils->is_tenant_resource_accessible($tenants_data, $row->id)) {
+            next;
+        }
+        push(
+            @data, {
+                "id"             => $row->id,
+                "name"           => $row->name,
+                "active"         => \$row->active,
+                "parentId"       => $row->parent_id,
+                "parentName"     => ( defined $row->parent_id ) ? 
$tenant_utils->get_tenant_by_id($tenants_data, $row->parent_id)->name : undef,
+            }
+        );
        }
        $self->success( \@data );
 }
@@ -68,20 +69,18 @@ sub show {
        my @data = ();
        my $rs_data = $self->db->resultset("Tenant")->search( { 'me.id' => $id 
});
        while ( my $row = $rs_data->next ) {
-               if ($tenant_utils->is_tenant_resource_accessible($tenants_data, 
$row->id)) {
-                       push(
-                               @data, {
-                                       "id"           => $row->id,
-                                       "name"         => $row->name,
-                                       "active"       => \$row->active,
-                                       "parentId"     => $row->parent_id,
-                                       "parentName"   => ( defined 
$row->parent_id ) ? $tenant_utils->get_tenant_by_id($tenants_data, 
$row->parent_id)->name : undef,
-                               }
-                       );
-               }
-               else {
-                       return $self->forbidden();
-               }
+               if 
(!$tenant_utils->is_tenant_resource_accessible($tenants_data, $row->id)) {
+            return $self->forbidden();
+        }
+        push(
+            @data, {
+                "id"           => $row->id,
+                "name"         => $row->name,
+                "active"       => \$row->active,
+                "parentId"     => $row->parent_id,
+                "parentName"   => ( defined $row->parent_id ) ? 
$tenant_utils->get_tenant_by_id($tenants_data, $row->parent_id)->name : undef,
+            }
+        );
        }
        $self->success( \@data );
 }

Reply via email to