lib/authtrail.rb in authtrail-0.2.0 vs lib/authtrail.rb in authtrail-0.2.1
- old
+ new
@@ -7,11 +7,11 @@
require "auth_trail/manager"
require "auth_trail/version"
module AuthTrail
class << self
- attr_accessor :exclude_method, :geocode, :track_method, :identity_method
+ attr_accessor :exclude_method, :geocode, :track_method, :identity_method, :job_queue
end
self.geocode = true
self.identity_method = lambda do |request, opts, user|
if user
user.try(:email)
@@ -43,11 +43,15 @@
unless exclude
if AuthTrail.track_method
AuthTrail.track_method.call(info)
else
- login_activity = LoginActivity.create!(info)
+ login_activity = LoginActivity.new
+ info.each do |k, v|
+ login_activity.try("#{k}=", v)
+ end
+ login_activity.save!
AuthTrail::GeocodeJob.perform_later(login_activity) if AuthTrail.geocode
end
end
end
@@ -64,7 +68,7 @@
Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
AuthTrail::Manager.after_set_user(user, auth, opts)
end
Warden::Manager.before_failure do |env, opts|
- AuthTrail::Manager.before_failure(env, opts)
+ AuthTrail::Manager.before_failure(env, opts) if opts[:message]
end