The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

30 lines
430 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 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