From 0638635dcd860b76169de2a4b333511ed4ef200c Mon Sep 17 00:00:00 2001 From: Chris Doherty Date: Fri, 13 Nov 2015 14:24:35 -0800 Subject: principal_endpoint.rb: comments. --- lib/chef_zero/endpoints/principal_endpoint.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/chef_zero') 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' -- cgit v1.2.1