module Devise::Models::Recoverable

def reset_password_period_valid?


reset_password_period_valid? # will always return false
# reset_password_within = 0.days

reset_password_period_valid? # returns false
# reset_password_within = 5.days and reset_password_sent_at = 5.days.ago

reset_password_period_valid? # returns true
# reset_password_within = 5.days and reset_password_sent_at = 4.days.ago

reset_password_period_valid? # returns true
# reset_password_within = 1.day and reset_password_sent_at = today

Example:

reset_password_within is a model configuration, must always be an integer value.
Returns true if the resource is not responding to reset_password_sent_at at all.
sending date does not exceed the confirm in time configured.
We do this by calculating if the difference between today and the
Checks if the reset password token sent is within the limit time.
def reset_password_period_valid?
  reset_password_sent_at && reset_password_sent_at.utc >= self.class.reset_password_within.ago
end