Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 662
jasonlfunk Avatar asked Sep 03 '25 03:09

jasonlfunk


1 Answers

Rubydoc - after_database_authentication method

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

like image 51
Cristian Bica Avatar answered Sep 05 '25 00:09

Cristian Bica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!