This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

application_controller.rb 652 Bytes
Newer Older
Valery Sizov's avatar
Valery Sizov committed
1
class Groups::ApplicationController < ApplicationController
2
  layout 'group'
3
  before_action :group
Valery Sizov's avatar
Valery Sizov committed
4
5

  private
6
7
8
9
10

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

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

Valery Sizov's avatar
Valery Sizov committed
21
  def authorize_admin_group!
22
    unless can?(current_user, :admin_group, group)
Valery Sizov's avatar
Valery Sizov committed
23
24
25
      return render_404
    end
  end
26

Douwe Maan's avatar
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
Valery Sizov's avatar
Valery Sizov committed
32
end