From 5b261be2b96d5aa3c48d09e1d27e0ee8aa70bb65 Mon Sep 17 00:00:00 2001 From: Jan Schulz-Hofen Date: Wed, 2 Dec 2015 18:23:37 +0800 Subject: [PATCH 1/7] Store user's IP address for the duration of the request This way, it will be available even if the request object is not. --- app/controllers/application_controller.rb | 2 ++ app/models/user.rb | 2 ++ config/locales/de.yml | 1 + config/locales/en.yml | 1 + 4 files changed, 6 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 98a2246..9bbc374 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -133,6 +133,8 @@ class ApplicationController < ActionController::Base end end end + # store current ip address in user object ephemerally + user.remote_ip = request.remote_ip if user user end diff --git a/app/models/user.rb b/app/models/user.rb index 4a6109f..cfffd7c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -92,6 +92,8 @@ class User < Principal attr_accessor :password, :password_confirmation, :generate_password attr_accessor :last_before_login_on + attr_accessor :remote_ip + # Prevents unauthorized assignments attr_protected :login, :admin, :password, :password_confirmation, :hashed_password diff --git a/config/locales/de.yml b/config/locales/de.yml index 0885f5b..0278273 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1148,6 +1148,7 @@ de: error_password_expired: Your password has expired or the administrator requires you to change it. field_time_entries_visibility: Time logs visibility + field_remote_ip: IP-Adresse label_parent_task_attributes: Parent tasks attributes label_parent_task_attributes_derived: Calculated from subtasks label_parent_task_attributes_independent: Independent of subtasks diff --git a/config/locales/en.yml b/config/locales/en.yml index 24d5fe7..23d2b55 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -351,6 +351,7 @@ en: field_time_entries_visibility: Time logs visibility field_total_estimated_hours: Total estimated time field_default_version: Default version + field_remote_ip: IP address setting_app_title: Application title setting_app_subtitle: Application subtitle -- 2.4.0