Search code examples
ruby-on-railsdevise

Devise: after successful login hook


In my rails app, I am using devise for my authentication system. I have a situation in which I want to encrypt some data using a key that is based off of the user's password. The easiest way that I can think to do this is during a successful sign in, to generate the user's private key from their plain-text password (passed in from the login form) and store that in the user's session. I don't really want to ask the user to enter their password more than once.

Does devise provide a way to specify a callback function after a successful login? Or is there a better way to do this?


Solution

  • Rubydoc - after_database_authentication method

    In the user model where you're using devise create a after_database_authentication instance method.