gitlab-org--gitlab-foss/app/controllers/groups/application_controller.rb

44 lines
848 B
Ruby
Raw Normal View History

2015-03-12 15:08:48 +00:00
class Groups::ApplicationController < ApplicationController
layout 'group'
2016-03-20 20:03:53 +00:00
skip_before_action :authenticate_user!
before_action :group
2015-03-12 15:08:48 +00:00
private
def group
2016-03-20 20:03:53 +00:00
unless @group
id = params[:group_id] || params[:id]
@group = Group.find_by(path: id)
unless @group && can?(current_user, :read_group, @group)
@group = nil
2016-03-20 20:03:53 +00:00
if current_user.nil?
authenticate_user!
else
render_404
end
end
end
2016-03-20 20:03:53 +00:00
@group
end
def group_projects
@projects ||= GroupProjectsFinder.new(group).execute(current_user)
end
2015-03-12 15:08:48 +00:00
def authorize_admin_group!
unless can?(current_user, :admin_group, group)
2015-03-12 15:08:48 +00:00
return render_404
end
end
2015-07-31 12:15:49 +00:00
def authorize_admin_group_member!
unless can?(current_user, :admin_group_member, group)
return render_403
end
end
2015-03-12 15:08:48 +00:00
end