Search code examples
javapasswordsverifyunlock

Unlock User Account After Invalid Password Entries


In my java application, I am going to lock the account if someone does not enter the correct password 6 times. I am going to add a field in my local database that indicates if a user's account is locked or not. However, how can I unlock this account? For example, I may want to unlock their account after 15 minutes. What is the best way to go about unlocking a user's account?


Solution

  • I would only store the date and time that indicates when the user account is going to be unblocked.

    So when that date/time is "larger" than the current time, the user is able to access the account.

    Whenever the date/time is "smaller" than the current time, the user isn't able too.