summaryrefslogtreecommitdiff
path: root/app/controllers/groups_controller.rb
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/controllers/groups_controller.rb
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/controllers/groups_controller.rb')
-rw-r--r--app/controllers/groups_controller.rb25
1 files changed, 19 insertions, 6 deletions
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index b927dd2f20a..f6f7e3b3ecd 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -1,4 +1,5 @@
class GroupsController < ApplicationController
+ skip_before_filter :authenticate_user!, only: [:show, :issues, :members, :merge_requests]
respond_to :html
before_filter :group, except: [:new, :create]
@@ -36,7 +37,7 @@ class GroupsController < ApplicationController
@events = Event.in_projects(project_ids)
@events = event_filter.apply_filter(@events)
@events = @events.limit(20).offset(params[:offset] || 0)
- @last_push = current_user.recent_push
+ @last_push = current_user.recent_push if current_user
respond_to do |format|
format.html
@@ -98,17 +99,21 @@ class GroupsController < ApplicationController
end
def projects
- @projects ||= current_user.authorized_projects.where(namespace_id: group.id).sorted_by_activity
+ @projects ||= group.projects_accessible_to(current_user).sorted_by_activity
end
def project_ids
- projects.map(&:id)
+ projects.pluck(:id)
end
# Dont allow unauthorized access to group
def authorize_read_group!
unless @group and (projects.present? or can?(current_user, :read_group, @group))
- return render_404
+ if current_user.nil?
+ return authenticate_user!
+ else
+ return render_404
+ end
end
end
@@ -131,13 +136,21 @@ class GroupsController < ApplicationController
def determine_layout
if [:new, :create].include?(action_name.to_sym)
'navless'
- else
+ elsif current_user
'group'
+ else
+ 'public_group'
end
end
def default_filter
- params[:scope] = 'assigned-to-me' if params[:scope].blank?
+ if params[:scope].blank?
+ if current_user
+ params[:scope] = 'assigned-to-me'
+ else
+ params[:scope] = 'all'
+ end
+ end
params[:state] = 'opened' if params[:state].blank?
params[:group_id] = @group.id
end