Originally posted by scorpioy
This is a good idea, which uses user provided email addresss as the authentication.
But I'm not sure why bother to have a 'status' column. Is it for the reason that if the user don't activate the account for a certain period, the account can be deleted from the database?
How to make that re-activate link (with encrypted password)?
Thanks a lot.
The user provided email address works best when bounced against the verification questions, so you have a pretty good idea that it's the right account.
I have a "status" column in case the account is inactive for say... 30 days, but I want to keep it in the DB for 90. This way, they can still reactivate their account without creating a new one. I have been known to not use an account for something for a month myself, so I give my users a break. At the 30 day mark, an email is sent to them reminding them to reactivate their account. That's why I use it, but I guess it's a matter of personal opinion.
To make the link, I generate a random access code and encrypt that. I also query the DB to pull their password, and I compile the link like so:
http://thedomain.com/activate.php?aid=ENCRYPTEDPW-ENCRYPTEDCODE
I also send the unencrypted access code so the user has to manually enter that.
When they click the link, the activate page prompts the user for the activation code I sent them and their user name. They enter that info, and it queries the DB for the username and encrypted PW combo. If it passes that, it encrypts their access code, and bounces it against the encrypted one in the URL. If it passes all of that, it activates the account, and sets the password to the access code, and advises the user they must create a new password to proceed. (If they don't enter a new password, they have to go through the entire procedure again, since the PW was changed to the encrypted access code, so the original link won't work for them.)
It may be overkill, it may have flaws, but it works for me, and my users. I haven't had any problems doing it this way, nor have any of my clients.