Module: Devise::AuditLog
- Defined in:
- lib/devise/audit_log.rb,
lib/devise/audit-log/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"- @@test =
true
Class Method Summary collapse
- .account_locked_event ⇒ Object
- .account_unlocked_event ⇒ Object
- .log(event, user, warden, env, options, success) ⇒ Object
- .login_event ⇒ Object
- .login_failure_event ⇒ Object
- .logout_event ⇒ Object
- .password_change_event ⇒ Object
- .password_reset_event ⇒ Object
- .password_reset_sent_event ⇒ Object
- .warden_strategy(warden_env) ⇒ Object
Class Method Details
.account_locked_event ⇒ Object
61 62 63 |
# File 'lib/devise/audit_log.rb', line 61 def self.account_locked_event "ACCOUNT LOCKED".freeze end |
.account_unlocked_event ⇒ Object
57 58 59 |
# File 'lib/devise/audit_log.rb', line 57 def self.account_unlocked_event "ACCOUNT UNLOCKED".freeze end |
.log(event, user, warden, env, options, success) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/devise/audit_log.rb', line 11 def self.log(event, user, warden, env, , 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 = [:scope].to_s ael.strategy = AuditLog.warden_strategy(warden) if warden ael.success = success ael.failure_reason = [: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 ⇒ Object
45 46 47 |
# File 'lib/devise/audit_log.rb', line 45 def self.login_event "LOGIN".freeze end |
.login_failure_event ⇒ Object
53 54 55 |
# File 'lib/devise/audit_log.rb', line 53 def self.login_failure_event "LOGIN FAILURE".freeze end |
.logout_event ⇒ Object
49 50 51 |
# File 'lib/devise/audit_log.rb', line 49 def self.logout_event "LOGOUT".freeze end |
.password_change_event ⇒ Object
73 74 75 |
# File 'lib/devise/audit_log.rb', line 73 def self.password_change_event "PASSWORD CHANGED".freeze end |
.password_reset_event ⇒ Object
65 66 67 |
# File 'lib/devise/audit_log.rb', line 65 def self.password_reset_event "PASSWORD RESET".freeze end |
.password_reset_sent_event ⇒ Object
69 70 71 |
# File 'lib/devise/audit_log.rb', line 69 def self.password_reset_sent_event "PASSWORD RESET SENT".freeze end |
.warden_strategy(warden_env) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/devise/audit_log.rb', line 38 def self.warden_strategy(warden_env) strategy = warden_env.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 |