I am trying to implement a time based OTP in my project where code generation and code validation will be done by same server. My whole requirement is to generate a OTP which should be valid for some time (configurable) and then send it to user email, with an option to resend the password to user's email.
I can understand once we generate a code for a particular secret key with a timestep, for that particular timestep it will generate same code for same key. but the problem in using this approach is Let's say timestep is 5 mins, a code is generated and valid for 5 mins. Now after 6 min, if I again send a code, then new code will only be valid for next 4 mins instead of 5 mins, since it was generated once previous code was expired.
ideally it should be valid for 5 mins from the time request is raised by user for the OTP.