about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-01-16 18:11:20 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-01-16 18:11:20 +0100
commitb61c3ddff8338432fdc287f6bebbf76a12859c17 (patch)
tree702e67a92f3a6e84feed3c06126b14a7e4ecab35 /app/serializers
parent07cb948f39464b11959fc506b673a90d9524e519 (diff)
parent462bc65112276f4cbfbeb1efd8cd452fda7d0f23 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `README.md`:
  Upstream added some text, but our README is completely different.
  Kept our README unchanged.
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/admin/account_serializer.rb13
-rw-r--r--app/serializers/rest/admin/ip_serializer.rb5
2 files changed, 14 insertions, 4 deletions
diff --git a/app/serializers/rest/admin/account_serializer.rb b/app/serializers/rest/admin/account_serializer.rb
index f579d3302..3480e8c5a 100644
--- a/app/serializers/rest/admin/account_serializer.rb
+++ b/app/serializers/rest/admin/account_serializer.rb
@@ -9,6 +9,7 @@ class REST::Admin::AccountSerializer < ActiveModel::Serializer
   attribute :created_by_application_id, if: :created_by_application?
   attribute :invited_by_account_id, if: :invited?
 
+  has_many :ips, serializer: REST::Admin::IpSerializer
   has_one :account, serializer: REST::AccountSerializer
 
   def id
@@ -19,10 +20,6 @@ class REST::Admin::AccountSerializer < ActiveModel::Serializer
     object.user_email
   end
 
-  def ip
-    object.user_current_sign_in_ip.to_s.presence
-  end
-
   def role
     object.user_role
   end
@@ -74,4 +71,12 @@ class REST::Admin::AccountSerializer < ActiveModel::Serializer
   def created_by_application?
     object.user&.created_by_application_id&.present?
   end
+
+  def ips
+    object.user&.ips
+  end
+
+  def ip
+    ips&.first
+  end
 end
diff --git a/app/serializers/rest/admin/ip_serializer.rb b/app/serializers/rest/admin/ip_serializer.rb
new file mode 100644
index 000000000..d11699dc4
--- /dev/null
+++ b/app/serializers/rest/admin/ip_serializer.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class REST::Admin::IpSerializer < ActiveModel::Serializer
+  attributes :ip, :used_at
+end