|
Posted by Alvaro G Vicario on 09/02/05 16:10
*** frizzle wrote/escribió (2 Sep 2005 05:53:34 -0700):
> I've read in a few places that you should *never*
> store original passwords in a mySQL DB.
> Now i wonder if you encrypt it (with MD5 ?), how should
> i create a lost password function, so the pass could be
> sent to a corresponding e-mail address?
Since you don't know user's password (that's the point) you cannot send it
back. You can however provide the user with a temporary URL where we can
set a new one.
Steps:
1) Create a long random ID. md5() and uniqid() may help
2) Store it in DB
3) Send user a mail message with the ID:
http://www.example.com/reset_password.php?id=xxxxxxxxxxxxx
4) In reset_password.php test whether ID exists in DB. If so, allow to set
pass
You can add all security features you can think of:
* Remove used ID
* Expire old unused IDs
* Store username or e-mail and ask for them
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Navigation:
[Reply to this message]
|