Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c17c6f9694a..0b442f5383a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -4,15 +4,24 @@ class UsersController < ApplicationController
def show
@user = User.find_by_username!(params[:username])
- @projects = Project.personal(@user).accessible_to(current_user)
unless current_user || @user.public_profile?
return authenticate_user!
end
- @groups = @user.groups.accessible_to(current_user)
- accessible_projects = @user.authorized_projects.accessible_to(current_user)
- @events = @user.recent_events.where(project_id: accessible_projects.pluck(:id)).limit(20)
+ # Projects user can view
+ authorized_projects_ids = ProjectsFinder.new.execute(current_user).pluck(:id)
+
+ @projects = @user.personal_projects.
+ where(id: authorized_projects_ids)
+
+ # Collect only groups common for both users
+ @groups = @user.groups & GroupsFinder.new.execute(current_user)
+
+ # Get user activity feed for projects common for both users
+ @events = @user.recent_events.
+ where(project_id: authorized_projects_ids).limit(20)
+
@title = @user.name
end