2022-07-04 17:41:40 -07: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 04:37:30 -07:00
|
|
|
role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
|
2022-07-04 17:41:40 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
|
|
|
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
|
|
|
|
end
|
|
|
|
end
|