module Devise::AuditLog

Constants

VERSION

Public Class Methods

account_locked_event() click to toggle source
# File lib/devise/audit_log.rb, line 61
def self.account_locked_event
  "ACCOUNT LOCKED".freeze
end
account_unlocked_event() click to toggle source
# File lib/devise/audit_log.rb, line 57
def self.account_unlocked_event
  "ACCOUNT UNLOCKED".freeze
end
log(event, user, warden, env, options, success) click to toggle source
# File lib/devise/audit_log.rb, line 11
def self.log(event, user, warden, env, options, success)
  env ||= warden.try(:env)
  warden ||= env["warden"] if env

  request = ActionDispatch::Request.new(env)

  ael = AuthenticationEventLog.new

  ael.event_type = event
  ael.user = user
  ael.ip = request.remote_ip if env
  ael.user_agent = request.user_agent if env
  ael.referrer = request.referrer if env
  ael.scope = options[:scope].to_s
  ael.strategy = AuditLog.warden_strategy(warden) if warden

  ael.success = success
  ael.failure_reason = options[:message].to_s if !ael.success

  ael.identity = user.try(:email) || request.params[ ael.scope ] && request.params[ ael.scope ][:email] || nil

  ael.action = "#{request.params[:controller]}##{request.params[:action]}" if request && env && request.params.has_key?(:controller)

  ael.save
end
login_event() click to toggle source
# File lib/devise/audit_log.rb, line 45
def self.login_event
  "LOGIN".freeze
end
login_failure_event() click to toggle source
# File lib/devise/audit_log.rb, line 53
def self.login_failure_event
  "LOGIN FAILURE".freeze
end
logout_event() click to toggle source
# File lib/devise/audit_log.rb, line 49
def self.logout_event
  "LOGOUT".freeze
end
password_change_event() click to toggle source
# File lib/devise/audit_log.rb, line 73
def self.password_change_event
  "PASSWORD CHANGED".freeze
end
password_reset_event() click to toggle source
# File lib/devise/audit_log.rb, line 65
def self.password_reset_event
  "PASSWORD RESET".freeze
end
password_reset_sent_event() click to toggle source
# File lib/devise/audit_log.rb, line 69
def self.password_reset_sent_event
  "PASSWORD RESET SENT".freeze
end
warden_strategy(warden_env) click to toggle source
# File lib/devise/audit_log.rb, line 38
def self.warden_strategy(warden_env)
  strategy = v.env["omniauth.auth"]["provider"] if warden_env.env["omniauth.auth"]
  strategy ||= warden_env.winning_strategy.class.name.split("::").last.underscore if warden_env.winning_strategy
  strategy ||= "database_authenticatable"
  strategy
end