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