invite_policy.rb 430 B

1234567891011121314151617181920212223242526272829
  1. # frozen_string_literal: true
  2. class InvitePolicy < ApplicationPolicy
  3. def index?
  4. staff?
  5. end
  6. def create?
  7. min_required_role?
  8. end
  9. def deactivate_all?
  10. admin?
  11. end
  12. def destroy?
  13. owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
  14. end
  15. private
  16. def owner?
  17. record.user_id == current_user&.id
  18. end
  19. def min_required_role?
  20. current_user&.role?(Setting.min_invite_role)
  21. end
  22. end