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