mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-13 22:59:19 +10:00
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Conflicts: app/controllers/autocomplete_controller.rb app/controllers/omniauth_callbacks_controller.rb app/controllers/projects/services_controller.rb app/helpers/projects_helper.rb app/services/audit_event_service.rb db/schema.rb doc/api/users.md doc/update/6.x-or-7.x-to-7.13.md features/project/project.feature
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
class AutocompleteController < ApplicationController
|
|
skip_before_action :authenticate_user!, only: [:users]
|
|
|
|
def users
|
|
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_group, group)
|
|
group.users
|
|
end
|
|
elsif current_user
|
|
User.all
|
|
end
|
|
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.non_ldap if params[:skip_ldap] == 'true'
|
|
@users = @users.search(params[:search]) if params[:search].present?
|
|
@users = @users.active
|
|
@users = @users.page(params[:page]).per(PER_PAGE)
|
|
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
|
|
end
|
|
|
|
def user
|
|
@user = User.find(params[:id])
|
|
render json: @user, only: [:name, :username, :id], methods: [:avatar_url]
|
|
end
|
|
end
|