Reputation: 5098
The flow is:
Now, how do I fetch user's ID based on the email address and encrypt it? Then what should link be? Like, what I want is fetch the User ID then encrypt it somehow so that the link doesn't contain the actual ID and that link will take the user to a page that will have textboxes to reset the password. I am just confused how to go about it.
Also is this the secure way? To reset a password like this?
Upvotes: 3
Views: 7250
Reputation: 12903
There is a railscast on exactly this subject: http://railscasts.com/episodes/274-remember-me-reset-password?view=asciicast
Upvotes: 0
Reputation: 7803
I usually create a new table in the database:
PasswordresetRequest with the following fields:
Flow is as follows:
This is pretty simple to implement and is secure enough for most sites.
Upvotes: 15
Reputation: 5291
There is any number of ways to go about doing this. If your major concern is security, one way could be to send a link that contains a guid parameter which you create and store on your end (in a db table, file or whatever suits you) together with the user id associated with it. When the request for password reset comes in, you check for the guid and look if there is one matching value in your db/file/whatever and proceed with the password reset. Don't forget to delete the guid from your storage to prevent multiple use of the same link.
Upvotes: 1