I'm currently finishing up a website where users are required to create a personal account in order to play a game that is hosted on the same website. What I'm currently having difficulty figuring out is how to implement secure password reset functionality for the users in the case of a forgotten password.
This is the process that is currently in place:
Step 1: User clicks on "Forgot Password" link on the website.
Step 2: User is brought to form and enters email address twice before being sent email.
Step 3: Email contains link to another form where the user can enter a new password twice for confirmation. Upon entering the second form, the system inserts a new record into my Recover_Password table in a database which contains the columns "id", "token", "created_at", and "expires_at".
This is the link -> (mywebsitename).com/form?id=99999&token=
Where "id" is the user's id and "token" is generated from do_hash($id . date('Y-m-d'))
Step 4: User completes form and is brought to the login page. The system clears the token record from the database and updates the user's current password from the user table.
Also I want to know what to do if the user tries refreshing the browser page when they are at the second form. I am currently only allowing access to the page if there is an id and a token value in the get parameters and that they both exist in the database.
I am using Codeigniter for the entire website and need to kow if this is a secure way of doing this and also how I should handle the token and the database. Thank you!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…