devise

https://github.com/plataformatec/devise

Ruby

Flexible authentication solution for Rails with Warden.

Devise::Models::Recoverable#reset_password_period_valid?

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

Example:

  # reset_password_within = 1.day and reset_password_sent_at = today
  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 = 5.days and reset_password_sent_at = 5.days.ago
  reset_password_period_valid?   # returns false

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

Source | Google | Stack overflow

Edit

git clone [email protected]:plataformatec/devise.git

cd devise

open lib/devise/models/recoverable.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Devise--Models--Recoverable-reset_password_period_valid--for-pr


# Commit to git

git add lib/devise/models/recoverable.rbgit commit -m "better docs for Devise::Models::Recoverable#reset_password_period_valid?"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Devise--Models--Recoverable-reset_password_period_valid--for-pr

hub pull-request


# Celebrate!