diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-12-25 11:23:29 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-12-25 11:23:29 +0000 |
commit | 92bc7038475104bad30a63fa324d9f1fd0836ce7 (patch) | |
tree | 1c5acf52ea74deadd4fd51243b05f390b6762008 /lib/api | |
parent | b1b5b2218fc7dc9b26c6375163f3a9fbd32f85c5 (diff) | |
parent | 5a8c65b508614dd8896ff8af7cad6e2b33fb7244 (diff) | |
download | gitlab-ce-92bc7038475104bad30a63fa324d9f1fd0836ce7.tar.gz |
Merge branch 'support-api-lookup-by-username' into 'master'
Add API support for looking up a user by username
Needed to support Huboard
See merge request !2089
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/users.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb index a98d668e02d..3400f0713ef 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -8,11 +8,17 @@ module API # # Example Request: # GET /users + # GET /users?search=Admin + # GET /users?username=root get do - @users = User.all - @users = @users.active if params[:active].present? - @users = @users.search(params[:search]) if params[:search].present? - @users = paginate @users + if params[:username].present? + @users = User.where(username: params[:username]) + else + @users = User.all + @users = @users.active if params[:active].present? + @users = @users.search(params[:search]) if params[:search].present? + @users = paginate @users + end if current_user.is_admin? present @users, with: Entities::UserFull |