mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 00:43:38 +08:00
ba6d4b2a8d
If you turn it on now, default all users to approved since they were previously. Also support approving a user that doesn't have a reviewable record (it will be created first.) This also includes a refactor to move class method calls to `DiscourseEvent` into an initializer. Otherwise the load order of classes makes a difference in the test environment and some settings might be triggered and others not, randomly.
45 lines
914 B
Ruby
45 lines
914 B
Ruby
require_dependency 'admin_user_list_serializer'
|
|
|
|
class AdminUserSerializer < AdminUserListSerializer
|
|
|
|
attributes :name,
|
|
:associated_accounts,
|
|
:can_send_activation_email,
|
|
:can_activate,
|
|
:can_deactivate,
|
|
:can_approve,
|
|
:ip_address,
|
|
:registration_ip_address
|
|
|
|
has_one :single_sign_on_record, serializer: SingleSignOnRecordSerializer, embed: :objects
|
|
|
|
def can_approve
|
|
scope.can_approve?(object)
|
|
end
|
|
|
|
def include_can_approve?
|
|
SiteSetting.must_approve_users
|
|
end
|
|
|
|
def can_send_activation_email
|
|
scope.can_send_activation_email?(object)
|
|
end
|
|
|
|
def can_activate
|
|
scope.can_activate?(object)
|
|
end
|
|
|
|
def can_deactivate
|
|
scope.can_deactivate?(object)
|
|
end
|
|
|
|
def ip_address
|
|
object.ip_address.try(:to_s)
|
|
end
|
|
|
|
def registration_ip_address
|
|
object.registration_ip_address.try(:to_s)
|
|
end
|
|
|
|
end
|