I assume that you store passwords hashed and salted. If not, do it. If so, you can store metadata in salt. For instance. salt [0-9a-z]{8} , but for temporary passwords it is ____[0-9a-z]{4} . (before downvoting, people, read on!) The fact is that a separate field can be edited separately from the hash field. Of course, this should never have happened, but it could happen. (unsuccessful requests, trendy system administrators, people who discovered phpmyadmin and believe that they understand the system, etc.) Saving the "state" of the password in salt prevents such chaos: when checking the password, you can always see which you confirmed with a temporary password , and you can always determine the user who needs to receive an invitation to "enter a new password."
source share