2017-11-28 00:07:59 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InvitePolicy < ApplicationPolicy
|
|
|
|
def index?
|
|
|
|
staff?
|
|
|
|
end
|
|
|
|
|
|
|
|
def create?
|
|
|
|
min_required_role?
|
|
|
|
end
|
|
|
|
|
2018-08-19 07:58:53 +09:00
|
|
|
def deactivate_all?
|
|
|
|
admin?
|
|
|
|
end
|
|
|
|
|
2017-11-28 00:07:59 +09:00
|
|
|
def destroy?
|
2017-12-01 20:26:19 +09:00
|
|
|
owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
|
2017-11-28 00:07:59 +09: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
|