The "done" way of doing password resets seems to be the following:
- Generate a temporary token (
zs8Abn27
) - Store token in a database along with an expiry time
- Email token to the user
- User goes to
/password_reset?t=zs8Abn27
- Token is checked against database for validity
- If valid user gets a new password which is stored in your database (salted and bcrypted, of course)
My question is if a hacker gets read/write access to your database wouldn't they just be able to create their own tokens, and gain access that way? Even if they just had read access they could use the tokens they can see to gain temporary access.
For the record this is entirely conceptual, I'm just curious how you could make a feature like this secure.