Logging fixed. Debugging finished.

This commit is contained in:
Christoph Haas 2021-03-03 01:29:26 +01:00
parent bc7541a2c9
commit b6dee6b93c
4 changed files with 4 additions and 16 deletions

View file

@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
# Do not mention passwords in the log file
# filter_parameter_logging :password
before_action :moderate_packages, :get_ip
before_action :moderate_packages
private
@ -28,9 +28,4 @@ class ApplicationController < ActionController::Base
def after_sign_out_path_for(resource_or_scope)
root_path
end
# Get the visitor's IP address to make it accessible to the Log model
def get_ip
@remote_ip = request.remote_ip
end
end

View file

@ -3,7 +3,7 @@ class Users::MySessionsController < Devise::SessionsController
# Hook after successful login
def after_login
Log.log "User #{current_user.email} logged in.", @remote_ip
Log.log "User #{current_user.email} logged in.", request.remote_ip
old_screenshots = session[:uploaded_screenshots]
if old_screenshots.to_a.length > 0
old_screenshots.each do |id|
@ -14,7 +14,7 @@ class Users::MySessionsController < Devise::SessionsController
end
# The message is probably confusing. Just add the screenshots.
# flash[:info] = "#{old_screenshots.to_a.length} uploads have been added to your account"
Log.log "Anonymously uploaded screenshots #{old_screenshots} added to #{current_user.email}.", @remote_ip
Log.log "Anonymously uploaded screenshots #{old_screenshots} added to #{current_user.email}.", request.remote_ip
session[:uploaded_screenshots] = nil
end
end

View file

@ -13,7 +13,7 @@ class Log < ApplicationRecord
order('id DESC')
}
def self.log(message, ip_address, section='frontend', level='info')
def self.log(message, ip_address='0.0.0.0', section='frontend', level='info')
log = Log.new
ip_address = request.remote_ip if defined? request

View file

@ -15,10 +15,3 @@
/ ' | Cookie is #{session[:token]}
= render 'cookies_eu/consent_banner', link: '/about#cookies'
p
tt =request.remote_ip
p
tt =@remote_ip
p
tt =ENV.inspect