This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2017-11-11 11:23:33 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserPolicy < ApplicationPolicy
|
|
|
|
def reset_password?
|
|
|
|
staff? && !record.staff?
|
|
|
|
end
|
|
|
|
|
2018-04-10 00:16:06 -07:00
|
|
|
def change_email?
|
|
|
|
staff? && !record.staff?
|
|
|
|
end
|
|
|
|
|
2017-11-11 11:23:33 -08:00
|
|
|
def disable_2fa?
|
|
|
|
admin? && !record.staff?
|
|
|
|
end
|
|
|
|
|
|
|
|
def confirm?
|
|
|
|
staff? && !record.confirmed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable?
|
2018-08-23 14:26:29 -07:00
|
|
|
staff?
|
2017-11-11 11:23:33 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def disable?
|
2018-08-23 14:26:29 -07:00
|
|
|
staff? && !record.admin?
|
2017-11-11 11:23:33 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def promote?
|
|
|
|
admin? && promoteable?
|
|
|
|
end
|
|
|
|
|
|
|
|
def demote?
|
|
|
|
admin? && !record.admin? && demoteable?
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def promoteable?
|
|
|
|
!record.staff? || !record.admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
def demoteable?
|
|
|
|
record.staff?
|
|
|
|
end
|
|
|
|
end
|