In Rails when using the Devise gem, how to log failed logins and lockups?

820 views Asked by At

I use the Devise to handle the authentications in my app and have public_activity to record things and have a log. Now I need to add a record to the log when a failed login occurs and when a account gets locked. How can I do this?

1

There are 1 answers

1
aratak On BEST ANSWER

You can use Warden's after_authentication hook as devise is built on warden. Put this in an config/initializers/devise_hooks.rb:

Warden::Manager.after_authentication do |user, auth, opts|
  # do something with user
end

Read details in wardens wiki