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