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