diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-07-27 11:22:35 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-07-27 11:22:35 +0200 |
commit | 0be6debb0b3350f35bf4b6a904c60da826314b3b (patch) | |
tree | 5a9281db4a97d8ffa8f3efc73e17fb0b11b17aef /app/controllers/autocomplete_controller.rb | |
parent | d371331a65070ce5b3ab9c210eac697062170c91 (diff) | |
parent | cd6046e1dd347f3a9bd7d062447aa25306a5755b (diff) | |
download | gitlab-ce-0be6debb0b3350f35bf4b6a904c60da826314b3b.tar.gz |
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq into backup-archive-permissions
Diffstat (limited to 'app/controllers/autocomplete_controller.rb')
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index 11af9895261..52e9c58b47c 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -1,22 +1,35 @@ class AutocompleteController < ApplicationController + skip_before_action :authenticate_user!, only: [:users] + def users - @users = - if params[:project_id].present? - project = Project.find(params[:project_id]) + begin + @users = + if params[:project_id].present? + project = Project.find(params[:project_id]) - if can?(current_user, :read_project, project) - project.team.users - end - elsif params[:group_id] - group = Group.find(params[:group_id]) + if can?(current_user, :read_project, project) + project.team.users + end + elsif params[:group_id] + group = Group.find(params[:group_id]) - if can?(current_user, :read_group, group) - group.users + if can?(current_user, :read_group, group) + group.users + end + elsif current_user + User.all end - else - User.all + rescue ActiveRecord::RecordNotFound + if current_user + return render json: {}, status: 404 end + end + + if @users.nil? && current_user.nil? + authenticate_user! + end + @users ||= User.none @users = @users.search(params[:search]) if params[:search].present? @users = @users.active @users = @users.page(params[:page]).per(PER_PAGE) |