debian-mirror-gitlab/app/controllers/groups/application_controller.rb

44 lines
848 B
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Groups::ApplicationController < ApplicationController
2015-09-11 14:41:01 +05:30
layout 'group'
2016-06-02 11:05:42 +05:30
skip_before_action :authenticate_user!
2015-11-26 14:37:03 +05:30
before_action :group
2015-04-26 12:48:37 +05:30
private
2015-11-26 14:37:03 +05:30
def group
2016-06-02 11:05:42 +05:30
unless @group
id = params[:group_id] || params[:id]
@group = Group.find_by(path: id)
unless @group && can?(current_user, :read_group, @group)
@group = nil
2015-11-26 14:37:03 +05:30
2016-06-02 11:05:42 +05:30
if current_user.nil?
authenticate_user!
else
render_404
end
2015-04-26 12:48:37 +05:30
end
end
2016-06-02 11:05:42 +05:30
@group
end
def group_projects
@projects ||= GroupProjectsFinder.new(group).execute(current_user)
2015-04-26 12:48:37 +05:30
end
2015-11-26 14:37:03 +05:30
2015-04-26 12:48:37 +05:30
def authorize_admin_group!
unless can?(current_user, :admin_group, group)
return render_404
end
end
2015-11-26 14:37:03 +05:30
2015-09-11 14:41:01 +05:30
def authorize_admin_group_member!
unless can?(current_user, :admin_group_member, group)
return render_403
2015-04-26 12:48:37 +05:30
end
end
end