lib/auth_trail/manager.rb in authtrail-0.1.1 vs lib/auth_trail/manager.rb in authtrail-0.1.2
- old
+ new
@@ -4,16 +4,14 @@
def after_set_user(user, auth, opts)
# do not raise an exception for tracking
AuthTrail.safely do
request = ActionDispatch::Request.new(auth.env)
- identity = user.try(:email)
-
AuthTrail.track(
strategy: detect_strategy(auth),
scope: opts[:scope].to_s,
- identity: identity,
+ identity: AuthTrail.identity_method.call(request, opts, user),
success: true,
request: request,
user: user
)
end
@@ -22,16 +20,13 @@
def before_failure(env, opts)
AuthTrail.safely do
if opts[:message]
request = ActionDispatch::Request.new(env)
- scope = opts[:scope]
- identity = request.params[scope] && request.params[scope][:email] rescue nil
-
AuthTrail.track(
strategy: detect_strategy(env["warden"]),
- scope: scope.to_s,
- identity: identity,
+ scope: opts[:scope].to_s,
+ identity: AuthTrail.identity_method.call(request, opts, nil),
success: false,
request: request,
failure_reason: opts[:message].to_s
)
end