# Retriving password,if users forgot password

**URL:** <https://www.ruby-forum.com/t/retriving-password-if-users-forgot-password/60633>\
**Category:** Rails\
**Created:** [May 16, 2006, 12:18pm UTC](https://www.ruby-forum.com/t/retriving-password-if-users-forgot-password/60633 "2006-05-16T12:18:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharmila\_devi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sharmila\_devi](https://www.ruby-forum.com/u/sharmila_devi)\
**Post date:** [May 16, 2006, 12:18pm UTC](https://www.ruby-forum.com/t/retriving-password-if-users-forgot-password/60633/1 "2006-05-16T12:18:28Z")

</div>

hi rails gals and guys  
im creating authentication using username and password,i wants to  
know how to retrive the username and password,if user forgot the  
username and password by asking secret question and secret answer  
e.g : what is your pet’s name?

if anyone knows how to implement tis,plz send your suggestions and  
ideas.

N.C.Sharmila

---

<div class="post-metadata">

**Author:** ![sharmila\_devi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@sharmila\_devi](https://www.ruby-forum.com/u/sharmila_devi)\
**Post date:** [May 16, 2006, 2:42pm UTC](https://www.ruby-forum.com/t/retriving-password-if-users-forgot-password/60633/2 "2006-05-16T14:42:39Z")

</div>

i would just create a separate db table for this. Generate some sort of  
md5  
hash and urlencode it into a “click here to create new password” link in  
the  
app.

when user clicks the url in the email they got, rails matches the md5  
string in the URL against an entry in the DB. If its there, delete the  
record , update user with a temp pass in the user table, and email it to  
the  
user.

Make sure to clean up the table every few days. IF they dont update  
their  
pass those records should be purged frequently.

adam
