summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorJason Hollingsworth <jhworth.developer@gmail.com>2014-02-13 14:45:51 -0600
committerJason Hollingsworth <jhworth.developer@gmail.com>2014-02-20 09:26:38 -0600
commit2f69213e3f32e2e4222f6335e790e2c778069014 (patch)
tree3734a9d41d2445a1557ed2f79c6cfa3de7dec215 /app/services
parent138e2a50b7d839bd37c21b2849df422f9dfef6bb (diff)
downloadgitlab-ce-2f69213e3f32e2e4222f6335e790e2c778069014.tar.gz
Allow access to groups with public projects.
Fixed Group avatars to only display when user has read permissions to at least one project in the group.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/filtering_service.rb8
-rw-r--r--app/services/search/global_service.rb6
2 files changed, 5 insertions, 9 deletions
diff --git a/app/services/filtering_service.rb b/app/services/filtering_service.rb
index 52537f7ba4f..cbbb04ccba9 100644
--- a/app/services/filtering_service.rb
+++ b/app/services/filtering_service.rb
@@ -41,16 +41,16 @@ class FilteringService
def init_collection
table_name = klass.table_name
- return klass.of_projects(Project.public_only) unless current_user
-
if project
- if current_user.can?(:read_project, project)
+ if project.public? || (current_user && current_user.can?(:read_project, project))
project.send(table_name)
else
[]
end
- else
+ elsif current_user && params[:authorized_only].presence
klass.of_projects(current_user.authorized_projects)
+ else
+ klass.of_projects(Project.accessible_to(current_user))
end
end
diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb
index c1130401578..09c7cb25dd5 100644
--- a/app/services/search/global_service.rb
+++ b/app/services/search/global_service.rb
@@ -11,12 +11,8 @@ module Search
query = Shellwords.shellescape(query) if query.present?
return result unless query.present?
- authorized_projects_ids = []
- authorized_projects_ids += current_user.authorized_projects.pluck(:id) if current_user
- authorized_projects_ids += Project.public_or_internal_only(current_user).pluck(:id)
-
group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
- projects = Project.where(id: authorized_projects_ids)
+ projects = Project.accessible_to(current_user)
projects = projects.where(namespace_id: group.id) if group
projects = projects.search(query)
project_ids = projects.pluck(:id)