1
0

invite_policy.rb 367 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. class InvitePolicy < ApplicationPolicy
  3. def index?
  4. role.can?(:manage_invites)
  5. end
  6. def create?
  7. role.can?(:invite_users)
  8. end
  9. def deactivate_all?
  10. role.can?(:manage_invites)
  11. end
  12. def destroy?
  13. owner? || role.can?(:manage_invites)
  14. end
  15. private
  16. def owner?
  17. record.user_id == current_user&.id
  18. end
  19. end