diff options
Diffstat (limited to 'lib/chef_zero/endpoints/principal_endpoint.rb')
-rw-r--r-- | lib/chef_zero/endpoints/principal_endpoint.rb | 4 |
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' |