Skip to content

Commit

Permalink
Include tenants from other regions in RBAC
Browse files Browse the repository at this point in the history
accessible_tenant_ids are tenant ids determined
for selection of resources by certain tenant strategy.

This update extend tenant ids about tenant ids from
other regions. This tenant ids are determined by
finding tenant with same name as we have in other
regions and tenant is used to get tenant ids
by certaion tenant strategy.
  • Loading branch information
lpichler committed Dec 10, 2018
1 parent 8fc86c3 commit 3f5517e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ def all_subprojects
self.class.descendants_of(self).where(:divisible => false)
end

def regional_tenants
self.class.regional_tenants(self)
end

def self.regional_tenants(tenant)
where(arel_table.grouping(arel_attribute(:name).eq(tenant.name)))
end

def accessible_tenant_ids(strategy = nil)
(strategy ? send(strategy) : []).append(id)
(strategy ? regional_tenants.map(&strategy.to_sym).flatten : []) + regional_tenants.ids
end

def name
Expand Down

0 comments on commit 3f5517e

Please sign in to comment.