Module: AuthTrail::Manager

Defined in:
lib/auth_trail/manager.rb

Class Method Summary collapse

Class Method Details

.after_set_user(user, auth, opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/auth_trail/manager.rb', line 4

def after_set_user(user, auth, opts)
  request = ActionDispatch::Request.new(auth.env)

  AuthTrail.track(
    strategy: detect_strategy(auth),
    scope: opts[:scope].to_s,
    identity: AuthTrail.identity_method.call(request, opts, user),
    success: true,
    request: request,
    user: user
  )
end

.before_failure(env, opts) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/auth_trail/manager.rb', line 17

def before_failure(env, opts)
  request = ActionDispatch::Request.new(env)

  AuthTrail.track(
    strategy: detect_strategy(env["warden"]),
    scope: opts[:scope].to_s,
    identity: AuthTrail.identity_method.call(request, opts, nil),
    success: false,
    request: request,
    failure_reason: opts[:message].to_s
  )
end