summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/finders/groups_finder.rb5
-rw-r--r--app/models/user.rb11
2 files changed, 15 insertions, 1 deletions
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb
index f68610e197c..03d145c4ccd 100644
--- a/app/finders/groups_finder.rb
+++ b/app/finders/groups_finder.rb
@@ -16,7 +16,10 @@ class GroupsFinder < UnionFinder
def all_groups
groups = []
- groups << current_user.authorized_groups if current_user
+ if current_user
+ groups << Group.member_self_and_descendants(current_user.id)
+ groups << current_user.groups_through_project_authorizations
+ end
groups << Group.unscoped.public_to_user(current_user)
groups
diff --git a/app/models/user.rb b/app/models/user.rb
index ad24ec0ec08..157e0948cd3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -492,6 +492,17 @@ class User < ActiveRecord::Base
Group.where("namespaces.id IN (#{union.to_sql})")
end
+ def groups_through_project_authorizations
+ projects = Project.joins(:project_authorizations).
+ where('project_authorizations.user_id = ?', id ).
+ joins(:route).
+ select('routes.path AS full_path')
+
+ Group.joins(:route).
+ joins("INNER JOIN (#{projects.to_sql}) project_paths
+ ON project_paths.full_path LIKE CONCAT(routes_namespaces.path, '/%')")
+ end
+
def nested_groups
Group.member_descendants(id)
end