BigW Consortium Gitlab

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

  private
6 7 8 9 10

  def group
    @group ||= Group.find_by(path: params[:group_id])
  end

11 12 13 14 15 16 17 18 19
  def authorize_read_group!
    unless @group and can?(current_user, :read_group, @group)
      if current_user.nil?
        return authenticate_user!
      else
        return render_404
      end
    end
  end
20

21
  def authorize_admin_group!
22
    unless can?(current_user, :admin_group, group)
23 24 25
      return render_404
    end
  end
26

Douwe Maan committed
27 28 29 30 31
  def authorize_admin_group_member!
    unless can?(current_user, :admin_group_member, group)
      return render_403
    end
  end
32
end