GRN2-310: Share Access now dynamically pulls the list of users from the server (#2380)

* Share Access now dynamically pulls the list of users from the server

* Merge users now dynamically pulls the list of users from the server

* Only return the information needed to the front-end
This commit is contained in:
Ahmad Farhat
2020-12-21 17:21:17 -05:00
committed by GitHub
parent 155d214215
commit 86e6056d3c
11 changed files with 111 additions and 40 deletions

View File

@ -197,6 +197,29 @@ class UsersController < ApplicationController
end
end
# GET /shared_access_list
def shared_access_list
# Don't allow searchs unless atleast 3 characters are passed
return redirect_to '/404' if params[:search].length < 3
roles_can_appear = []
Role.where(provider: @user_domain).each do |role|
roles_can_appear << role.name if role.get_permission("can_appear_in_share_list") && role.priority >= 0
end
initial_list = User.select(:uid, :name)
.where.not(uid: current_user.uid)
.with_role(roles_can_appear)
.shared_list_search(params[:search])
initial_list = initial_list.where(provider: @user_domain) if Rails.configuration.loadbalanced_configuration
# Respond with JSON object of users
respond_to do |format|
format.json { render body: initial_list.to_json }
end
end
private
def find_user