forked from treehouse/mastodon
Fix not all of account's active IPs showing up in admin UI (#12909)
parent
91e4955e08
commit
02063c245c
|
@ -290,6 +290,21 @@ class User < ApplicationRecord
|
||||||
setting_display_media == 'hide_all'
|
setting_display_media == 'hide_all'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def recent_ips
|
||||||
|
@recent_ips ||= begin
|
||||||
|
arr = []
|
||||||
|
|
||||||
|
session_activations.each do |session_activation|
|
||||||
|
arr << [session_activation.updated_at, session_activation.ip]
|
||||||
|
end
|
||||||
|
|
||||||
|
arr << [current_sign_in_at, current_sign_in_ip] if current_sign_in_ip.present?
|
||||||
|
arr << [last_sign_in_at, last_sign_in_ip] if last_sign_in_ip.present?
|
||||||
|
|
||||||
|
arr.sort_by(&:first).uniq(&:last).reverse!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def send_devise_notification(notification, *args)
|
def send_devise_notification(notification, *args)
|
||||||
|
|
|
@ -139,12 +139,12 @@
|
||||||
%time.formatted{ datetime: @account.created_at.iso8601, title: l(@account.created_at) }= l @account.created_at
|
%time.formatted{ datetime: @account.created_at.iso8601, title: l(@account.created_at) }= l @account.created_at
|
||||||
%td
|
%td
|
||||||
|
|
||||||
%tr
|
- @account.user.recent_ips.each_with_index do |(_, ip), i|
|
||||||
%th= t('admin.accounts.most_recent_ip')
|
%tr
|
||||||
%td= @account.user_current_sign_in_ip
|
- if i.zero?
|
||||||
%td
|
%th{ rowspan: @account.user.recent_ips.size }= t('admin.accounts.most_recent_ip')
|
||||||
- if @account.user_current_sign_in_ip
|
%td= ip
|
||||||
= table_link_to 'search', t('admin.accounts.search_same_ip'), admin_accounts_path(ip: @account.user_current_sign_in_ip)
|
%td= table_link_to 'search', t('admin.accounts.search_same_ip'), admin_accounts_path(ip: ip)
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%th= t('admin.accounts.most_recent_activity')
|
%th= t('admin.accounts.most_recent_activity')
|
||||||
|
|
Loading…
Reference in New Issue