You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
390 B

  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 destroy?
  10. owner? || (Setting.min_invite_role == 'admin' ? admin? : staff?)
  11. end
  12. private
  13. def owner?
  14. record.user_id == current_user&.id
  15. end
  16. def min_required_role?
  17. current_user&.role?(Setting.min_invite_role)
  18. end
  19. end