2017-11-11 19:23:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class UserPolicy < ApplicationPolicy
|
|
|
|
def reset_password?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_user_access) && role.overrides?(record.role)
|
2017-11-11 19:23:33 +00:00
|
|
|
end
|
|
|
|
|
2018-04-10 07:16:06 +00:00
|
|
|
def change_email?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_user_access) && role.overrides?(record.role)
|
2018-04-10 07:16:06 +00:00
|
|
|
end
|
|
|
|
|
2017-11-11 19:23:33 +00:00
|
|
|
def disable_2fa?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_user_access) && role.overrides?(record.role)
|
|
|
|
end
|
|
|
|
|
|
|
|
def change_role?
|
|
|
|
role.can?(:manage_roles) && role.overrides?(record.role)
|
2017-11-11 19:23:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def confirm?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_user_access) && !record.confirmed?
|
2017-11-11 19:23:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_users)
|
2017-11-11 19:23:33 +00:00
|
|
|
end
|
|
|
|
|
2019-03-14 04:28:30 +00:00
|
|
|
def approve?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_users) && !record.approved?
|
2019-03-14 04:28:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reject?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_users) && !record.approved?
|
2019-03-14 04:28:30 +00:00
|
|
|
end
|
|
|
|
|
2017-11-11 19:23:33 +00:00
|
|
|
def disable?
|
2022-07-05 00:41:40 +00:00
|
|
|
role.can?(:manage_users) && role.overrides?(record.role)
|
2017-11-11 19:23:33 +00:00
|
|
|
end
|
|
|
|
end
|