This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2022-07-05 02:41:40 +02: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 13:37:30 +02:00
|
|
|
role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
|
2022-07-05 02:41:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
|
|
|
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
|
|
|
|
end
|
|
|
|
end
|