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.
 
 
 
 

46 rivejä
609 B

  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. staff?
  17. end
  18. def disable?
  19. staff? && !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