Module: UserAuthTokensMixin
- Extended by:
- ActiveSupport::Concern
- Included in:
- UserAuthTokenSerializer
- Defined in:
- app/serializers/concerns/user_auth_tokens_mixin.rb
Instance Method Summary collapse
- #browser ⇒ Object
- #client_ip ⇒ Object
- #device ⇒ Object
- #icon ⇒ Object
- #location ⇒ Object
- #os ⇒ Object
Instance Method Details
#browser ⇒ Object
17 18 19 20 |
# File 'app/serializers/concerns/user_auth_tokens_mixin.rb', line 17 def browser val = BrowserDetection.browser(object.user_agent) I18n.t("user_auth_tokens.browser.#{val}") end |
#client_ip ⇒ Object
8 9 10 |
# File 'app/serializers/concerns/user_auth_tokens_mixin.rb', line 8 def client_ip object.client_ip.to_s end |
#device ⇒ Object
22 23 24 25 |
# File 'app/serializers/concerns/user_auth_tokens_mixin.rb', line 22 def device val = BrowserDetection.device(object.user_agent) I18n.t("user_auth_tokens.device.#{val}") end |
#icon ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/serializers/concerns/user_auth_tokens_mixin.rb', line 32 def icon case BrowserDetection.os(object.user_agent) when :android "fab-android" when :chromeos "fab-chrome" when :macos, :ios "fab-apple" when :linux "fab-linux" when :windows "fab-windows" else "question" end end |
#location ⇒ Object
12 13 14 15 |
# File 'app/serializers/concerns/user_auth_tokens_mixin.rb', line 12 def location ipinfo = DiscourseIpInfo.get(client_ip, locale: I18n.locale) ipinfo[:location].presence || I18n.t("staff_action_logs.unknown") end |
#os ⇒ Object
27 28 29 30 |
# File 'app/serializers/concerns/user_auth_tokens_mixin.rb', line 27 def os val = BrowserDetection.os(object.user_agent) I18n.t("user_auth_tokens.os.#{val}") end |