logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

user_policy.rb (609B)


  1. # frozen_string_literal: true
  2. class UserPolicy < ApplicationPolicy
  3. def reset_password?
  4. staff? && !record.staff?
  5. end
  6. def change_email?
  7. staff? && !record.staff?
  8. end
  9. def disable_2fa?
  10. admin? && !record.staff?
  11. end
  12. def confirm?
  13. staff? && !record.confirmed?
  14. end
  15. def enable?
  16. admin?
  17. end
  18. def disable?
  19. admin? && !record.admin?
  20. end
  21. def promote?
  22. admin? && promoteable?
  23. end
  24. def demote?
  25. admin? && !record.admin? && demoteable?
  26. end
  27. private
  28. def promoteable?
  29. !record.staff? || !record.admin?
  30. end
  31. def demoteable?
  32. record.staff?
  33. end
  34. end