about summary refs log tree commit diff
path: root/app/policies/invite_policy.rb
blob: e5c68af19bc9b5185f21dccff24a18ded68e7f78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

class InvitePolicy < ApplicationPolicy
  def index?
    staff?
  end

  def create?
    min_required_role?
  end

  def destroy?
    owner? || staff?
  end

  private

  def owner?
    record.user_id == current_user&.id
  end

  def min_required_role?
    current_user&.role?(Setting.min_invite_role)
  end
end