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