I want to have a user management system. I allow users to change their password, but I should have restrictions. For instance that the new password is not any of the last five passwords used.
How should I maintain a list of the last five passwords?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I already posted a comment above. But just to answer your question. You should create an
old_passwordstable with theuser_id,old_password,creation_datein it.Store the date when the password is first created in the main table. When changing the password copy the old password and that original date to
creation_datein theold_passwordstable. Then update the password, and set the date to now in the main user table.You should also probably drop a unique index on
user_id, creation_date.To delete:
(You should test this code BTW.) You run this query when a person updates their password.