summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@chef.io>2015-11-13 14:24:35 -0800
committerChris Doherty <cdoherty@chef.io>2015-11-13 14:24:35 -0800
commit0638635dcd860b76169de2a4b333511ed4ef200c (patch)
treed9a177360dcc96c8f36333a7b14bd0822c6b9be5
parentbc1921cb2ba1d68456e410f8838609b14c05973d (diff)
downloadchef-zero-0638635dcd860b76169de2a4b333511ed4ef200c.tar.gz
principal_endpoint.rb: comments.
-rw-r--r--lib/chef_zero/endpoints/principal_endpoint.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/chef_zero/endpoints/principal_endpoint.rb b/lib/chef_zero/endpoints/principal_endpoint.rb
index 8cad07c..b1f4efb 100644
--- a/lib/chef_zero/endpoints/principal_endpoint.rb
+++ b/lib/chef_zero/endpoints/principal_endpoint.rb
@@ -8,16 +8,20 @@ module ChefZero
class PrincipalEndpoint < RestBase
def get(request)
name = request.rest_path[-1]
+ # If /organizations/ORG/users/NAME exists, use this user (only org members have precedence over clients). hey are an org member.
json = get_data(request, request.rest_path[0..1] + [ 'users', name ], :nil)
if json
type = 'user'
org_member = true
else
+ # If /organizations/ORG/clients/NAME exists, use the client.
json = get_data(request, request.rest_path[0..1] + [ 'clients', name ], :nil)
if json
type = 'client'
org_member = true
else
+ # If there is no client with that name, check for a user (/users/NAME) and return that with
+ # org_member = false.
json = get_data(request, [ 'users', name ], :nil)
if json
type = 'user'