about summary refs log tree commit diff
path: root/app/policies/user_role_policy.rb
blob: 7019637fcc3b7cacb0b7523771e398befc8392ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class UserRolePolicy < ApplicationPolicy
  def index?
    role.can?(:manage_roles)
  end

  def create?
    role.can?(:manage_roles)
  end

  def update?
    role.can?(:manage_roles) && role.overrides?(record)
  end

  def destroy?
    !record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
  end
end