DEV: Refactor location string builders. (#6794)

This commit is contained in:
Bianca Nenciu 2018-12-20 11:23:05 +02:00 committed by Régis Hanol
parent bd6d482d11
commit a06d310855
2 changed files with 2 additions and 6 deletions

View File

@ -35,7 +35,7 @@ class UserNotifications < ActionMailer::Base
def suspicious_login(user, opts = {})
ipinfo = DiscourseIpInfo.get(opts[:client_ip])
location = [ipinfo[:city], ipinfo[:region], ipinfo[:country]].reject(&:blank?).join(", ")
location = ipinfo[:location]
browser = BrowserDetection.browser(opts[:user_agent])
device = BrowserDetection.device(opts[:user_agent])
os = BrowserDetection.os(opts[:user_agent])

View File

@ -21,11 +21,7 @@ module UserAuthTokensMixin
def location
ipinfo = DiscourseIpInfo.get(client_ip, locale: I18n.locale)
location = [ipinfo[:city], ipinfo[:region], ipinfo[:country]].reject { |x| x.blank? }.join(", ")
return I18n.t('staff_action_logs.unknown') if location.blank?
location
ipinfo[:location].presence || I18n.t('staff_action_logs.unknown')
end
def browser