summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-05-23 15:48:13 +0200
committerToon Claes <toon@gitlab.com>2017-05-30 22:45:59 +0200
commit07fc79e7c53a4fa7c4dd33835b905dfa8a609ff8 (patch)
treecc9fc22af268c599f8a0f5f157b73462ba70062a
parent4fda13b68eb7da27be5e74cac6d3d537502b19f7 (diff)
downloadgitlab-ce-07fc79e7c53a4fa7c4dd33835b905dfa8a609ff8.tar.gz
Handle `membership` in ProjectFinder
The ProjectFinder supports the `non_public` parameter. This can be used to find only projects the user is member of.
-rw-r--r--lib/api/helpers.rb4
-rw-r--r--lib/api/projects.rb5
2 files changed, 4 insertions, 5 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 226a7ddd50e..0dc33eb2097 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -257,10 +257,6 @@ module API
# project helpers
def filter_projects(projects)
- if params[:membership]
- projects = projects.merge(current_user.authorized_projects)
- end
-
if params[:owned]
projects = projects.merge(current_user.owned_projects)
end
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index ef09dfa0102..bb03480f1ee 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -68,7 +68,10 @@ module API
end
def present_projects(options = {})
- projects = ProjectsFinder.new(current_user: current_user).execute
+ finder_params = {}
+ finder_params[:non_public] = true if params[:membership].present?
+
+ projects = ProjectsFinder.new(current_user: current_user, params: finder_params).execute
projects = filter_projects(projects)
projects = projects.with_statistics if params[:statistics]
projects = projects.with_issues_enabled if params[:with_issues_enabled]