BigW Consortium Gitlab

application_controller.rb 848 Bytes
Newer Older
1
class Groups::ApplicationController < ApplicationController
2
  layout 'group'
3 4

  skip_before_action :authenticate_user!
5
  before_action :group
6 7

  private
8 9

  def group
10 11 12 13 14 15
    unless @group
      id = params[:group_id] || params[:id]
      @group = Group.find_by(path: id)

      unless @group && can?(current_user, :read_group, @group)
        @group = nil
16

17 18 19 20 21
        if current_user.nil?
          authenticate_user!
        else
          render_404
        end
22 23
      end
    end
24 25 26 27 28 29

    @group
  end

  def group_projects
    @projects ||= GroupProjectsFinder.new(group).execute(current_user)
30
  end
31

32
  def authorize_admin_group!
33
    unless can?(current_user, :admin_group, group)
34 35 36
      return render_404
    end
  end
37

Douwe Maan committed
38 39 40 41 42
  def authorize_admin_group_member!
    unless can?(current_user, :admin_group_member, group)
      return render_403
    end
  end
43
end