From adb8b8285818fe01294a56d1214c00fe70144a9a Mon Sep 17 00:00:00 2001
From: Douglas Barbosa Alexandre <dbalexandre@gmail.com>
Date: Fri, 28 Oct 2016 00:50:38 -0200
Subject: [PATCH] Skip authorization check when searching for labels on
 IssuableFinder

---
 app/finders/issuable_finder.rb | 4 ++--
 app/finders/labels_finder.rb   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index e27986ef95b..cc2073081b5 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -126,7 +126,7 @@ class IssuableFinder
 
     @labels =
       if labels? && !filter_by_no_label?
-        LabelsFinder.new(current_user, project_ids: projects, title: label_names).execute
+        LabelsFinder.new(current_user, project_ids: projects, title: label_names).execute(skip_authorization: true)
       else
         Label.none
       end
@@ -273,7 +273,7 @@ class IssuableFinder
         items = items.with_label(label_names, params[:sort])
 
         if projects
-          label_ids = LabelsFinder.new(current_user, project_ids: projects).execute.select(:id)
+          label_ids = LabelsFinder.new(current_user, project_ids: projects).execute(skip_authorization: true).select(:id)
           items = items.where(labels: { id: label_ids })
         end
       end
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index 18d1396d78b..865f093f04a 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -22,7 +22,7 @@ class LabelsFinder < UnionFinder
       label_ids << project.group.labels if project.group.present?
       label_ids << project.labels
     else
-      label_ids << Label.where(group_id: projects.group_ids.uniq)
+      label_ids << Label.where(group_id: projects.group_ids)
       label_ids << Label.where(project_id: projects.select(:id))
     end
 
-- 
GitLab