diff options
author | Stan Hu <stanhu@gmail.com> | 2015-12-12 22:02:05 -0800 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-12-24 07:57:13 -0800 |
commit | 5a8c65b508614dd8896ff8af7cad6e2b33fb7244 (patch) | |
tree | c0b86bbbbc15b74829ba2e97d8b3014d42b4bb9c /lib/api | |
parent | 1a23af485cd755738f4051e04132b1eb93fc3fab (diff) | |
download | gitlab-ce-5a8c65b508614dd8896ff8af7cad6e2b33fb7244.tar.gz |
Add API support for looking up a user by username
Needed to support Huboard
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 |