This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2017-11-11 20:23:33 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserPolicy < ApplicationPolicy
|
|
|
|
def reset_password?
|
|
|
|
staff? && !record.staff?
|
|
|
|
end
|
|
|
|
|
2018-04-10 09:16:06 +02:00
|
|
|
def change_email?
|
|
|
|
staff? && !record.staff?
|
|
|
|
end
|
|
|
|
|
2017-11-11 20:23:33 +01:00
|
|
|
def disable_2fa?
|
|
|
|
admin? && !record.staff?
|
|
|
|
end
|
|
|
|
|
|
|
|
def confirm?
|
|
|
|
staff? && !record.confirmed?
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable?
|
|
|
|
admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable?
|
|
|
|
admin? && !record.admin?
|
|
|
|
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
|