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