Log successful and failed login attempts in a separate log file
We log the login parameter and the request IP address. Quoting the ENS: > [op.acc.5.r5.1] Se registrarán los accesos con éxito y los fallidos.
This commit is contained in:
24
lib/authentication_logger.rb
Normal file
24
lib/authentication_logger.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class AuthenticationLogger
|
||||
@loggers = {}
|
||||
|
||||
class << self
|
||||
def log(message)
|
||||
logger.info(message)
|
||||
end
|
||||
|
||||
def path
|
||||
Rails.root.join("log", Tenant.subfolder_path, "authentication.log")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def logger
|
||||
@loggers[Apartment::Tenant.current] ||= build_logger
|
||||
end
|
||||
|
||||
def build_logger
|
||||
FileUtils.mkdir_p(File.dirname(path))
|
||||
ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(path, level: :info))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user