This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-11-27 07:07:59 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InvitePolicy < ApplicationPolicy
|
|
|
|
def index?
|
|
|
|
staff?
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
|
|
|
min_required_role?
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy?
|
2017-12-01 03:26:19 -08:00
|
|
|
owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
|
2017-11-27 07:07:59 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def owner?
|
|
|
|
record.user_id == current_user&.id
|
|
|
|
end
|
|
|
|
|
|
|
|
def min_required_role?
|
|
|
|
current_user&.role?(Setting.min_invite_role)
|
|
|
|
end
|
|
|
|
end
|