2022-07-05 01:41:40 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserRolePolicy < ApplicationPolicy
|
|
|
|
def index?
|
|
|
|
role.can?(:manage_roles)
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
|
|
|
role.can?(:manage_roles)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update?
|
2022-07-17 12:37:30 +01:00
|
|
|
role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
|
2022-07-05 01:41:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
|
|
|
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
|
|
|
|
end
|
|
|
|
end
|