diff options
author | Stan Hu <stanhu@gmail.com> | 2015-08-20 21:33:00 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-08-21 13:47:56 -0700 |
commit | 3715a0f29b6758b3075abb6f28ee24c4eb8ed427 (patch) | |
tree | 96675d33d770fd308c535a11bde4dad40cefadb0 /app/controllers/autocomplete_controller.rb | |
parent | 55fc58bda4a5592f2f8deaecec9526fbe4eecd6f (diff) | |
download | gitlab-ce-3715a0f29b6758b3075abb6f28ee24c4eb8ed427.tar.gz |
Fix bug preventing invite by e-mail
This was broken in 70f5291808 as a result of introducing the ability to filter by current user.
Closes #2320
Diffstat (limited to 'app/controllers/autocomplete_controller.rb')
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index 5c3ca8e23c9..904d26a39f4 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -33,8 +33,14 @@ class AutocompleteController < ApplicationController @users = @users.search(params[:search]) if params[:search].present? @users = @users.active @users = @users.page(params[:page]).per(PER_PAGE) - # Always include current user if available to filter by "Me" - @users = User.find(@users.pluck(:id) + [current_user.id]).uniq if current_user + + unless params[:search].present? + # Include current user if available to filter by "Me" + if params[:current_user] && current_user + @users = [*@users, current_user].uniq + end + end + render json: @users, only: [:name, :username, :id], methods: [:avatar_url] end |