summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Walsh <mwalsh@synopsys.com>2017-06-20 08:53:28 -0600
committerMatt Walsh <mwalsh@synopsys.com>2017-06-20 08:53:28 -0600
commit02ad2841d8d6260309f260e661e1f7eec7a8e0a1 (patch)
treee14ad1ab47d33919623dee887245064cc253b41b
parent40cd50829944db38fac07014e5fa00eafa3d1bc7 (diff)
downloadgitlab-ce-02ad2841d8d6260309f260e661e1f7eec7a8e0a1.tar.gz
Allow discover by userid - issue 28517
-rw-r--r--lib/api/internal.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 9ec418edea4..479ee16a611 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -71,11 +71,16 @@ module API
end
#
- # Discover user by ssh key
+ # Discover user by ssh key or user id
#
get "/discover" do
- key = Key.find(params[:key_id])
- present key.user, with: Entities::UserSafe
+ if params[:key_id]
+ key = Key.find(params[:key_id])
+ user = key.user
+ elsif params[:user_id]
+ user = User.find_by(id: params[:user_id])
+ end
+ present user, with: Entities::UserSafe
end
get "/check" do